|
No, my intention was firmly to subclass the Datagrid I've had a browse through sourceforge,asp.net and gotdot.net but couldn't find much. I'm also surprised that there are virtually no freeware/opensource .net forums out there besides the www.gotdotnet.com one. Perhaps the Microsoft community are unscrupulous (sp?) when it comes to people paying for their time.
|
|
|
|
|
There's plenty of free source here on CodeProject and many other places. The definition of "open source" is a very lax one.
Personally, I like to give back to the community by offerring bait, lures, and tackles so that others may learn to fish. I can't think of a single reason to spend my time (and perhaps others') on a commercial grade solution without getting something in return besides a few "thanks" and lots of support requests. People have to eat and shelter themselves. That's just my $0.02 (US) on open source vs. commercial software.
As far as extending the DataGrid , you could do that but you seem to be developing more of a composite control, which it's typically better to encapsulate (in order to control, for one). It'll also make rendering (including placement, etc.) a little easier.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
|
You can set the IsBackground property of all threads true.
Once all foreground threads belonging to a process have terminated, the common language runtime ends the process by invoking Abort on any background threads that are still alive.
Otherwise use the ApplicationExit event of Application class and abort the threads yourself inside the event handler.
|
|
|
|
|
Another way - albeit it a potentionally dangerous one - is to call Environment.Exit , which unloads the CLR - which unloads your application - immediately. No clean-up code is executed at all and the OS will reclaim memory used by the process. This will stop any execution dead in its tracks.
Another common implementation is to signal threads or have threads query for a "stop" request while running (in a loop, you could do this at the beginning of each iteration, for example). They could then stop themselves gracefully instead of throwing ThreadAbortException s that may be undesirable and often difficult to catch (for more information on that, see the Application.ThreadException or AppDomain.UnhandledException events).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I have one minor correction related to what you wrote (although the quality of your advice is as high as ever, don't get me wrong). Calling Environment.Exit() doesn't mean that no clean-up code is executed, just that no normal shutdown code written into the application will be executed. If you run this, you'll probably agree with me:
<br />
using System;<br />
<br />
namespace Test {<br />
<br />
class ExitTest {<br />
<br />
[STAThread]<br />
static void Main(string[] args) {<br />
ExitTest et = new ExitTest();<br />
Environment.Exit(0);<br />
}<br />
<br />
~ExitTest() {<br />
Console.WriteLine( "Destroying..." );<br />
}<br />
}<br />
<br />
}<br />
I think that if someone is going to use Environment.Exit() , it should only be used in emergency situations if they need their code to exit quickly, or to return a specific exit code to the OS (which can also be done using a variant of Main() ). If the case is the former, all objects using important resources should implement destructor methods to make sure that no matter what, they're cleaned up properly.
Regards,
Jeff Varszegi
|
|
|
|
|
Hi everybody!
Last week I received the task to develop and implement a simulation and analysis environment for a flow control algorithm. I have no restrictions for this except that the flow control algorithm will be implemented in C++.
Because i recently worked much with C# and really like it, i want to use this instead of C++. But this of course brings up the question of how to insert the algorithm into the environment.?
How good are the chances to port this algorithm to C# and are there maybe some existing tools?
Otherwise, i thought of creating a .NET Class Library with the algorithm and use this in my C#-Code, because i've read it's no problem to mix programming languages that way.?
Can someone tell me if it's possible what i want to do or give me some suggestions.
Thx in advance!
|
|
|
|
|
Troschi wrote:
Otherwise, i thought of creating a .NET Class Library with the algorithm and use this in my C#-Code
A .NET Class Library is written in any language targeting the CLR, like C#. You could implement this in C#, yes, but .NET itself is not a language - it's a Framework comprised of the Common Language Runtime (CLR), the Common Type System (CTS), and the Common Interface Language (CIL).
If you need to implement the algorithm in C++, consider using the Managed C++ extensions and write it using a mixed-mode assembly. Any language targeting the CLR (like C#, VB.NET, et. al.) can use it like any other assembly written in any other language (it all compiles down to Microsoft Intermediate Language, or MSIL anyway, though native instructions in C/C++ are compiled to native code, making your assembly less portable).
You seem to be a little confused about what .NET is. I suggest you read about the Microsoft .NET Framework[^] to learn more.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks for answering.
I know .Net is not a language. Maybe i didn't express myself well by using the term ".NET Class Library". I meant creating a Class Library targeting the CLR which is written in C++.
Anyway, it's good to know that i can use it in languages targeting the CLR. As i said i read about it but never used it until now. Just wanted to be sure it works. Also i will read more about .NET Framework, always had this in mind but never found the time.
Nevertheless I have another question. I don't write the flow control algorithm myself, just the simulation and analysis environment. Therefor I have no real influence on the implementation of the algorithm. I'm a bit afraid that when i want to create the .Net Class Library with the completed algorithm some bad difficulties, incompabilities or so occur. I don't really know how to say this. Any guideline to avoid such things?
Hope i could make myself clear.
|
|
|
|
|
If you can't dictate how the algorithm is developed, don't fret. You have several options: create a MC++ assembly that uses the C/C++ APIs even in a __gc class (managed class declaration). Compile it as an assembly and you'll have no problems.
If the algorithm is comprised of only a few exported functions (hopefully C-style, but C++ name mangling is not really a problem either), then consider writing your wrapper component in C# and just P/Invoke the functions you need, correctly defining any structs and consts you might need to marshal.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi!.
I have write an application and I want to know if there is a way to protected the resulting EXE agains a reverse engineer.
Obfuscating the assemblies is just a step in the real protection, 'cause if someone edit, the resulting obfuscate exe's and dll's, with the tool provide for Microsoft, (ildasm), could see the objetcs, (with a confusing name that's true, but however it can see it).
Thank you
|
|
|
|
|
There's no way beyond obfuscation. Frameworks that use intermediate code like .NET and Java all suffer from that, but that's part of what makes them highly portable. If you don't want your application to be easily reverse-engineered, then choose a language that compiles down to native code like C/C++.
Also, for every obfuscator, there's a deobfuscator. If you still want to keep your code managed, then consider a mixed-mode Managed C++ (MC++) assembly whereby sensitive code is written using unmanaged C/C++ and classes are exposed using the managed extensions so that they can easily be used by any other languages targeting the CLR, i.e. C#, VB.NET, and many others.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thank you for answer me.
If I use MC++, how can I write a class with unmanaged code, (with the result of native-code), 'cause I want the UI code managed, but many classes that I wrote have code that I want to protect so it should be native-code and all this building in one EXE. It could be that possible?.
Thank you.
J Herrera
|
|
|
|
|
As I said, you create a mixed-mode assembly that includes both unmanaged code and managed code, then turn compilation to the CLR on (/clr switch on the compiler, also available somewhere in the project configuration). See Managed Extensions for C++ Programming[^] in the Visual Studio .NET documentation for more information.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I am working on the ID3 algorithm send by Roosevelt and it is very useful but I have some questions and I need a fast answer to them
1) If I have a file containing the attributes can I read it from there and how?
2) How can I maiplate the output to show me each node with it value?
Thanks
Cherif
|
|
|
|
|
You can use a FileStream and seek to the last 128 bytes for ID3v1, or search the stream until you find "TAG" for ID3v2 and higher, IIRC. Just see the specs for ID3 for more information.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I think he was mentioning the ID3 data mining algorithm...
I see dumb people
|
|
|
|
|
I want to know how to make the target node of the minig algorithm accepts strings
|
|
|
|
|
I don't quite understand what is ID3v1 or ID3v2. I have a text file containing the attributes of each node and I want to read this file and put it in the attribute array. the problem is that each attribute must be givin a name and I don't know exactly how many attributes I have before reading he file so I need to create new attributes on the fly. It is like having a loop that crates new attributes.
i will be gratefull if you include a code or algorithm to this part because I've been working in it for 1 week and still no result (you can refer to the Roosevelt code to see what I mean)
Thanks
Cherif
|
|
|
|
|
I'm not sure I understand your original problem, since I thought you were asking about how to read ID3 tags from supported file types like MP3s.
If all you need to do is create arrays of information, either use an ArrayList (which internally re-dimensions arrays when they grow beyond the Capacity ), or use a Hashtable for a dictionary-based (i.e., name/value pairs) "collection" so you can refer to things by name.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Could someone please point me to some info on the how to make my app open a file when it is double clicked in explorer.
Thank you,
Sam
|
|
|
|
|
Then why is your subject entitled "Open with..."? This is what happens when you DON'T have an association.
File associations are easy. See Creating a File Association[^] in the Platform SDK.
This can easily be incorporated into an installer, too. See previous posts in this forum (click "Search comments") for information about how to do this correctly with a Windows Installer package.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
thanks...I needed that too
|
|
|
|
|
Sweet, that shows how to link an extension to the application, set the icon for the extension, and extend the shell, but...
How do I handle the link in my app? Do I need to test for a registry entry, is the program called with arguments, do I override function? I can't find anything on this subject.
Thanks again for the help.
-Sam
//you know you've been coding for too long when you hit Ctrl-Shift-B instead of submit
|
|
|
|
|
When you double-click on the file, Windows Explorer executes your application and passes the path to the file as the first argument. So lets say you have a FilePath property on your main application form, and/or a constructor which takes the path of the file. You could do something like this:
public class MainForm : Form
{
static void Main(string[] args)
{
MainForm form = null;
if (args.Length > 0)
form = new MainForm(args[0]);
else
form = new MainForm();
Application.Run(form);
}
public MainForm() : this(null)
{
}
public MainForm(string filePath)
{
this.filePath = filePath;
}
private string filePath;
public string FilePath
{
get { return this.filePath; }
set { this.filePath = value; }
}
}
Microsoft MVP, Visual C#
My Articles
|
|
|
|