Importing System.dll and so on.
Is it possible to add these DLLs in your code, in stead of adding them as a reference? I find it annoying every time I want to use them that i have to make a whole new solution in stead of just one file.
I tried to use DLLImort, but I guess it isn't ment to import them like this. Is there any way like in C++?
The code I tested (in case it is just Monodevelop) that don't understand it:
Code:
using System.Runtime.InteropServices;
[DllImport("System.dll")]
[DllImport("System.Drawing.dll")]
[DllImport("System.Windows.Forms.dll")]
class MessageBoxHelloWorld
{
public static void Main()
{
System.Windows.Forms.MessageBox.Show("Hello, world!");
}
}
- ØØ -
Re: Importing System.dll and so on.
using System;
using System.Drawing;
using System.Windows.Forms;
is that what you mean?
What do you mean by "i have to make a whole new solution in stead of just one file"?
Re: Importing System.dll and so on.
I don't need those using directives since I am writing all the name spaces with dots in between in that example.
But in order to use those name spaces, I have to add DLL files as reference, since the namespaces are in the DLL files.
The problem is: Is it possible to add those with code (as in C++) or do you have to manualy add them to references in your IDE. I can't remember exactly since it has been a year ++ since I did C# in VS, but I think VS adds the references automaticaly for you, but you can see them in the solution explorer. But if you just want to make a cs file, and NOT a whole solution (with all the solution files) then you can't add references, since those are stored in the solution files. So I was wondering if you could add those DLLs with code in a .cs file.
- ØØ -
Re: Importing System.dll and so on.
in microsoft's version I believe the only way to do it is to have a project file and add the references to that. I dont think you can do it without that, unless mono allows you
Re: Importing System.dll and so on.
Well, it didn't look like it worked the way I did. I think that is only to get functions from DLLs, might try to ask on the Monodevelop mailing list on monday, if no one has a solution before that.
- ØØ -
Re: Importing System.dll and so on.
I don't thinnk this will be possible because unlike *.h header files, DLLs are already compiled. Not all DLL's are present on all computers and I think this wouldn't work.
$0.02
Re: Importing System.dll and so on.
It works in C++ though....
Re: Importing System.dll and so on.
you could make a project file and manually add the dll's to it:D
Re: Importing System.dll and so on.
Yeah...but then Monodevelop won't detect it. And then I could just as well, just compile the single line like this:
mcs -r:System.dll -r:System.Windows.Forms.dll Helloworld.cs
or something like that...
- ØØ -
Re: Importing System.dll and so on.
Looks like I found the solution here. Havn't tested it yet. But should work in most cases.
http://www.codeproject.com/csharp/AddRefVSNET.asp
- ØØ -