We're using our .NET Assembly DLL within native C++ through COM (CCW).
Whenever I make new version of my DLL, I have to send two files (.dll and corresponding .tlb) to crew that's using it in their code.
Is it possible to embed .tlb file as a resource in .NET DLL file?
It is not exactly straightforward to do this with Visual Studio .NET, but it can be done. At a basic level, what you have to do is this:
Generate your TLB file, e.g., "YourLibrary.tlb".
Create a Win32 resource script file called, for example, "YourLibrary.rc" using a text editor (such as Notepad, or File/New/File.../Text File in Visual Studio).
In the script file, type the following text verbatim (but substitute your actual TLB file name of course):
1 typelib "YourLibrary.tlb"
Save the script file to the same folder as the TLB file.
From a Visual Studio Command Prompt, change to the folder with the script file and compile it using the following command:
rc YourLibrary.rc
This will generate a Win32 resource file in the same folder called "YourLibrary.res".
In Visual Studio, right click the project node (e.g., "YourLibrary") in the Solution Explorer and select Properties.
On the Application tab, under "Resources", select the "Resource File" option and browse to the "YourLibrary.res" file from step 5.
Save and rebuild the project.
The TLB will now be embedded as a resource in the DLL such that other COM applications can read it.
If you regenerate the TLB file later you will need to repeat step 5 to recompile the resource file, and step 8 to embed the new version in the DLL.
All that said, you may be able to automate some of this with Build Events or by putting custom MSBuild targets into your project file, but that is a whole other discussion.
Related
I want to compile my c# project with roslyn and I need to generate resources files with resgen
resgen /compile Resources.resx
and then I get all *.resources file from my projects and embed to assembleis
myCompilationOfProject.Emit(ms,manifestResources : ListOfResources);
but I have a project with EDMX file and find out that I must some resources that there is in this project ( *.csdl,*.msl,*.ssdl that is in myDatabaseProject\Debug\obj\edmxResourcesToEmbed folder ) .Visual studio embedded these files I saw these files with a reflector. I added these files to my compiled project with roslyn and it works well.
I want to khow how visual studio generat theses file and from which file and which tools ? I would generate these resources file programmatically in my c# code
I have Disassembled a WPF (Prism).dll file (Microsoft.Practices.Prism.UnityExxtensions.dll) using ILDASM, there I got 3 files with extensions like .IL, .res and .g.resources. I have changed the version number of a referenced file in metadata of the .IL file. Now I need to again Assemble it into a .dll.
You can use ilasm tool.
I have heard about this workaround too. Make a new application. Add all the resource files then select all files and change the build action to embedded resources for all files.
In Eclipse when I implement a class library and I'm ready to deploy, I usually export and package it into a JAR file that later you can just add to the build path in another project. Is there an equivalent feature in Visual Studio? Is there a proper way to "publish" a class library and package it into a dll file to later add as a reference in another project? Or do you just usually go and dig for it in the bin folder yourself?
Most VS projects compile into a DLL. If you want your DLL to be "published" to some particular location when you build, you can use build events which can also package up your dll (you could call a batch script, for example, that takes care of that for you).
Is there a proper way to "publish" a class library and package it into a dll file to later add as a reference in another project? Or do you just usually go and dig for it in the bin folder yourself?
Sure, just add the bin\debug\yourdll.dll or bin\release\yourdll.dll as a reference in your other project, or otherwise to the location you moved it to in your build event. No need to go digging for it every time.
Change the output type to 'release' or 'Debug'.
Go to Build, Build Solution (Or f5)
Navigate to: The Solution Bin folder for release or debug.
3a. You can quickly navigate to the solution folder by right clicking the solution in the
'Solution explorer' and selecting 'Open folder in File Explorer'.
The compiled DLL file will be in that directory. (bin\release or bin\debug)
Trying to integrate a dll which seems to require an xml file in a .net 4.0 C# PowerPoint Add-In this error occurs whenever calling a method from the dll:
Error: Could not find file 'C:\Users\user1\AppData\Local\assembly\dl3\6ZEM2ZRW.ODN\V57AVN2Y.7LO\c7a2a88f\00b83183_9e96c501\ASCII.xml'.
The xml file in questions is included in the project as "Content" with "Copy to output directory = always".
To me it looks like Visual Studio loads the dll into a kind of "local assembly directory" instead of using it directly from the output?
I have the source of the original dll library and a sample c# project implementing it.
In the dll it seems to be referenced like this:
public const string DefaultAsciiDataFile = #".\ASCII.xml";
In the sample project I could not find reference (using search in files), I'm not sure how the files get even loaded.
How can I get the dll to find the xml?
Update: Just putting the xml file into this temp file helps for now. Found the idea in this question.
Maybe it's related to my project being an add-in?
(Ideally without modifying / rebuilding the dll)
C# projects use a .resx file for resources. This is fine for strings, but it does not seem to have the equivilant of the old VERSIONINFO resource that the C++ project .rc files supported.
I can not believe that Microsoft has given up the idea of keeping track of executable versions ... so is there some VERSIONINFO-equivilent resource used with the .resx resource file? How do you bind version information into a C# project?
If you select a project in the Visual Studio Solution Explorer, right-click Project/Properties, and click the Assembly Information button, you can put your version information in the dialog box that opens.
The version information is stored in the resulting assembly's manifest.