Results 1 to 10 of 10

Thread: Importing System.dll and so on.

  1. #1

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    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!");
         }
    }
    
    
    
    
    - ØØ -

  2. #2
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    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"?
    I don't live here any more.

  3. #3

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    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.


    - ØØ -

  4. #4
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    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
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  5. #5

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    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.


    - ØØ -

  6. #6
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    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
    I don't live here any more.

  7. #7

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: Importing System.dll and so on.

    It works in C++ though....

  8. #8
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    Re: Importing System.dll and so on.

    you could make a project file and manually add the dll's to it
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  9. #9

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    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...


    - ØØ -

  10. #10

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    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

    - ØØ -

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width