I'm making a load of code bits that will eventually be used in another C# program long term, but I may want to use it in various other apps, and I need to use it easily now as it gradually develops. So I've written a few C#.net DLLs in Visual Studio Express 2017. Two of which reference a 3rd-party DLL (one of which was installed by other software, one of which I just pointed at in Visual Studio), and one of my DLLs references my other 2 DLLs. I've ticked the boxes to COM register my ones and I'm now happily using them from Excel/VBA.
But how do I install it on another Win10 machine in simple steps though, so I can use the same spreadsheets and automation on those computers? (preferably with some explanation of what the steps are actually doing?) I haven't had any luck with the other options I've googled, maybe they're not "idiot proof" enough for me, or my DLLs have dependencies on other DLLs, or I'm getting them from the wrong place.
I assume these are 64-bit DLLs (they're complied for 'Any CPU') so I
want to copy them into the 64-bit place (syswow64)? Or should they go
in system32 as well?
I guess I get them from my 'release', not 'debug' folders?
I also have .pdb and .tlb as well as .dll. Do I need these? Maybe they're the missing piece of the jigsaw?
What's the difference between regsvr and regasm and what should I be using? (Or both).
Also is there a simple way to make a DLL copying and COM registering installer app? And if yes, does that still apply if it's VS Express
2017?
Thanks for the help!
Related
I set <Deterministic> to true in my .csproj file as specified in the docs to create deterministic outputs.
I need any team member on any machine to be able to create the exactly same DLL when builds our project.
However, when I build, and compare my DLL files to my teammate's DLL files, I see that some files are different.
How can I debug this? How can I find out where the problem might be?
We have the same versions of .NET SDK and Visual Studio. We have the same versions of Windows. Almost everything is the same.
I want to know how can I troubleshoot this problem. Thank you.
I want to add Scintilla to my project, because I want to make my own HTML editor.
Visual Studio doesn't want to add a reference to SciLexer.dll and SciLexer64.dll.
I've dont everything in the installation instructions.
I'm using Windows 7 64 bit and Visual Studio 2012.
It's pretty clear in the documentation. You want to reference only ScintillaNET.dll in your project, and ensure that SciLexer.dll and SciLexer64.dll are somewhere in your path. The ScintillaNET.dll is a wrapper around the two other unmanaged DLL's, and used P/Invoke to call them.
This means that you need to ensure that the unmanaged DLL's are deployed with your application.
Here is a short video of my error.
It is obvious that I have something wrong between 32-bit and 64-bit. However I cant find anything that holds my hand enough to walk through the solution in Visual Studio 2012.
Can anyone give me a more detailed explanation of what and how to change in my settings?
The "startup project" (the one that builds the .exe file) determines whether the process will run 32 or 64 bits. Any library that is referenced must support the same "bitness".
If you use libraries that requires a specific CPU type, you should change the "Target CPU" property in the "Build" tab of the project properties of the project that creates the main executable to that CPU type.
Any managed library that you use, that does not depend on cpu-specific libraries can be compiled as "Any CPU".
I don't know the library you're using, but this link makes me think it requires a 32 bit build.
EDIT: I just realized I only know earlier versions of Visual Studio, so the option may be located elsewhere in 2012.
I've dealt with a similar issue just a few days ago. It wasn't as straightforward as one would expect (given the error), I had to use dependency walker in order to check if all needed dependencies of my dlls were in the correct format, turned out my dll was importing an incorrect dependency.
Dependency Walker
I have been trying to monitor video memory for a highly performance intensive program.
So I used the NVIDIA CUDA libraries in a C++ Visual Studio Application to collect the data I need.
Unfortunately I need a package that can be used with Ruby, C# and the Software Testing tools my company has.
So I decided to compile a C++ DLL and import it into a C# Visual Studio Project for testing.
I was able to compile the DLL but importing it into my Visual C# Program has been an issue.
I right Click on References -> Add Reference. Then I click on the Browse tab and browse to the location of my DLL; "TestProgram.dll" and I click "OK"
Then I get the following Error message "A reference to C:.... could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component."
What I have tried so far:
1. Importing the DLL from several different locations on my system.
2. Moving the DLL into my Solution Explorer and importing it
3. Using the "Invoke" method: [DllImport("PathToMyDll")]
4. Using the "Invoke" method with just my dll name.
5. Typing 'using' path to my DLL
6. Exporting the dll as a .lib file instead
What am I doing wrong? I thought that if I exported a DLL using Visual Studio 2010 then surely that same DLL could be Added into a Visual Studio 2010 project.
Well, is it a valid Assembly or COM component? Just because it's a C++ DLL doesn't mean it can be used with just a reference, in fact, most can't. It needs to be a managed DLL or a COM object. If it's none of those, then you have to invoke unmanaged code from a managed assembly. That means defining each function in a stub.
More info here: how to call a C++ dll exported function from c#
Be aware, you also have to deal with 64/32 bit issues, since if the DLL is compiled for 32 bit, you can't use it in a 64 bit application.
I found the solution to this problem. CUDA creates a Windows Console Application project. So the solution was to just use that instead of a DLL.
This worked well because Ruby, Test Complete and Visual C# can read the output from a basic .exe console program (with some work).
The compiled exe is simple. All I need to do is pass in an integer as an argument when I launch the program and the program will get the data I need from my NVIDIA card.
The challenge now will be finding a good way to interface with the .exe.
To build an Autocad application I use C# 4.0.
My application has two module one for 2005 and another for 2010 autocad. it uses special dll's of autocad ,but face some difficulty of finishing it up .All should be universal for 2005 and 2010 autocad since dll's has the same name it was impossible for the app to differ autocad versions.it create problem for autocad interop dll's in reference.help me to use different dll for different module.
Application has two modules(2005,2010)
Special dll
2005 and 2010 dll has same name.
Application fail to distinguish dll
Help me to use different same name dll in one application.
Note:In individual project they work perfectly.
need help to use same name dll in one application .
If have any query please ask ,Thanks in advanced.
I've a similar application, it works for autocad from 2006 to 2013 (both x86 and x64) and for bricscad v12-v13.
To solve it I did a visual studio project for each architecture, each of those projects refers different .dll depending on autocad version. In particular each of those projects refers AcDbMgd.dll, AcMgd.dll, Autodesk.AutoCAD.Interop and Autodesk.AutoCAD.Interop.Common, those dll are specific for each autocad architecture.
You have to pay attention that all of the referenced dll are in copy local FALSE!
In my case all the projects are compiled in different folders but it's not obligatory if you assign a different assembly name for each project.
Thanks to the fact that AutoCAD API are the same from 2006 to 2012 (2013 has some differences), the source code is separated from those projects, each project include it as a linked source file (go to the project in the solution explorer -> right click -> add existing item -> select the source file and press "add as link"). In this way you have the same source code for all the projects but they are compiled including different autocad dlls.
In my case there were also some troubles because BricsCAD has sometimes different API with respect to AutoCAD. To solve this few cases I've set a conditional compilation symbol and used it like so:
#if BricsCad
CADAPI.ApplicationServices.Application.SystemVariableChanged += new CADAPI.ApplicationServices.SystemVariableChangedEventHandler(Application_SystemVariableChanged);
#else
CADDB.LayoutManager.Current.LayoutSwitched += new CADDB.LayoutEventHandler(Current_LayoutSwitched);
#endif
Tell me if you need further information. BTW I think your main problem is the copy local = true for autocad Dlls.