My problems with C # data and DLL

I am trying to see if it is possible to retrieve data from a DLL. I did some research and found that you can store application resources in a DLL. What I could not find was information to tell me how to do this. There is an MS article that explains how to access resources in a satellite DLL, but I honestly don't know, this is what I'm looking for. http://msdn.microsoft.com/en-us/library/ms165653.aspx I tried to use some of the codes, but there are some "FileNotFoundExceptions".

The rest of the DLL information is displayed: classes, objects, etc. I just added the DLL as a resource to my Visual Studio project and added it using "use". I just don’t know how to get to the meat, if possible.

+4
source share
4 answers

If dll is.net, you can use reflection.

Using System.Reflection; .... Assembly A= Assembly.LoadFrom(YouDllFileName); string[] STA; STA= A.GetManifestResourceNames(); // STA contains all the resource names in the dll ... // to extract them Stream str= A.GetManifestResourceStream(STA[I]); // then, you can make that stream became a file if you wish 

You can also extract .net assembly resources using ildasm

+1
source

I'm not quite sure what you can use based on your description, but a few general pointers ...

If you are trying to find files added to the project, you do this:

Right-click a resource in the Solution Explorer, click properties, and set Build Action to Embedded Resource.

For lines and icons, add a .resx file to the project and paste them there. If this is what you are doing and still run into problems, check out the build action.

0
source

Since you say you can add a DLL to the using directive, you can probably use the methods provided by the DLL. If you do not have documentation for the DLL, you just need to try using the object browser to find out what it has to offer.

suggest:

 using MyDll; 

You should be able to call methods as follows:

 string x = MyDll.SomeType.GetValue(); 

Is that what you asked?

0
source

There are two types of dlls.

  • Managed dll - dll written in any .net language (e.g. csharp)
    The link you provide works with managed DLLs.
  • Unmanaged dll - classic dll c / cpp.
    in this case, you need to establish a connection between the managed (your code) and the unmanaged.

To find out what type of your dll you need to add this dll as a reference.
In the opened visual studio project, right-click on the links (in the Solution Explorer).
Then "add link" -> browse-> add your dll.
Then, through the links, you can see your dll.
Right-click on it and add a view to the Object Overview.
If you see something like the class "c" inside the namespace "b", you are working with a managed dll.
In Object Explorer, you can learn a lot about your DLL (perhaps this is more important than just fetching resources).

At this point, you can have Daniel Dolz respond to you.

0
source

Source: https://habr.com/ru/post/1307055/


All Articles