My project has many COM dependecies.
as you know , in order to use COM dlls you must register them using REGSVR32.
this creates alot of mess when immigrating to other computer/ installation.
currently got them all in a dependecy folder. and got a batch file that runs pre build and registers all of the dlls.
how do you manage your com dlls?
what is the easiest way to find out if your com dll registered, and if not to register it?
how to make sure that if I get lastest version of the project to a computer that never used it before.
(only got visual studio) I can just do rebuild all and all will compile and work. and as cleanly and as simple as possible.
do you put all your resources as part of the soultion? I mean project documents mail conversation and etc? looks like visual studio can manage all those easily but is this a known practice?
i am using studio 2010
Related
I have made a C# class library, which uses other dll's made by others in the company, for COM interop. It is being used with MS Excel 2013 and works fine on my development machine.
To test it on other machines, i have copied the output (dll's and .tlb file) to my system 32 folder. I have then registered the dll's using regasm (using the /codebase argument). Finally, i added the reference to the .tlb in the Excel VBA editor. Allthough it is a little tedious with 6 dll's, the regasm works fine.
The next step is to distribute the Excel sheet to relevant users in the company, where most are located in different parts of the world in different deparments. This means i do not know what programs that are installed that are needed(for example .net 4.5). Also, since most people in the company know little about the command line, using the above procedure is not only a little tedious, but scares people. I therefore would like to make an installer.
Since i use VS2013, i have installed a plug in that allows me to make a setup file.
I have found this question, which is almost the same as mine, but i don't need the GAC part. How do i modify the procedure to my needs? - i have tried to follow the procedure given, but i get an error stating one of the dll's i use in my own, does not have a strong name and cannot be in the GAC. Build therefore fails. How do i rectify the above? - do i need to fix the dll or can i do this without the GAC-part?
How do i automate the installation process of my dll(s)? - The alternative right now is to roll out VS2013 to the users and make them run the project and register that way (Does VS express suffice?).
Thanks in advance - i started this project with little experience, so learning curve is a bit steep.
It's not clear to me exactly what you want to do, but that link does tell you how to register Dlls - just look at the properties of each Dll and set the register property. You can also add your tlb file to your setup, and mark that to be registered too. If that isn't what you're trying to do then edit the question.
p.s. Don't put tham in the system folder - pout them in your company's/app's common files folder.
I am a Visual Studio 2013 Newbie who is trying to figure out how to build a C DLL in Visual Studio and then invoke the functions exported by the C lib from within a C# app. I've got everything building, but I cannot figure out the proper way of getting the DLL included with the app build so that it will actually load properly when using [DLLImport()]. I currently get a System.DllNotFoundException when attempting to invoke a function from the library from within my C# class.
I have setup a VS 2013 solution which contains the following projects:
HelloWorldLib.Shared :
Shared project that contains the .cpp and .h files for the DLL
HelloWorldLib.Windows :
Win 8.1 C++ project that references the shared project and builds the DLL for Win 8.1
MyApp-Win.Windows :
C# project for Win 8.1 that wants to make use of the HelloWorldLib.Windows.dll produced by the HelloWorldLib.windows build
I have been looking over many SO questions and answers. For instance, I think my question is similar to this one, which doesn't appear to have been answered in any useful way:
Interop, Native DLL and Visual Studio build process
Some of the other answers suggested adding a file reference to the DLL, but how would I do that and keep the proper Debug/Release versions? Given that all of these projects are being built within the same solution, and there are build dependencies between them, it feels like there should be a straightforward way to set this up.
BTW, I am using the shared project setups, as my ultimate goal is to figure out how to get this all working with Xamarin to target iOS, Win, Win Phone, Mac and Android. So that we can use a common C/C++ layer for our high performance requirement code, and the reference it from the UI layers on the various platforms.
This is a pretty straight-forward problem, easy to identify if you look where the built files end up. The C++ build system has a different strategy than the managed build system. It by default writes the build output to the solution directory's Debug directory. Your C# project however builds to its bin\Debug directory and requires all dependent DLLs to be present there.
So, by default, your C# program can never find the DLL, it is in the wrong directory and Windows doesn't look there. Nor is MSBuild smart enough to discover this by itself, like it can for managed DLLs, it cannot see that you program depends on the C++ DLL.
Two basic ways to work around this:
Change the C++ project's Output Directory setting
Write a post-build event for your C# project that uses xcopy.exe to copy the DLL.
Unfortunately things aren't that easy, at least not yet. I was going to have a meeting with Microsoft C++ team but that got postponed, similar functionality you are after was one of the things on my wishlist (building managed C++/CLI wrappers for Xamarin.iOS and Android).
Currently, if you can, the easiest option is to wrap C++ code inside a DLL that exposes C interface. Then build it with XCode and Android NDK. If you can't then the next option is to create Objective-C binding project that wraps the C++ code inside Objective C classes for iOS. For Android either create Java wrapper or use SWIG. Both of these options are cumbersome which is why C API should be the first choice you investigate.
I know it's not the answer you were hoping for but reusing C++ code is way more complicated than reusing C# or even C.
I have a console application built in visual studio 2010.
When I actually build the project I am getting .exe file under \bin\Debug\MyProj.exe.
When I Paste and run this .exe from other location it is expecting other files too.
Any thoughts how can I make this as Stand alone exe file.
There should be other DLL's in the Debug library. You need those to run your exe.
If there are no DLL's there, make sure you set the 'Copy local' property of the required references to True, and build again.
If you want to make a standalone program, you should create a new Setup project in your solution. Include the Primary Output from your application project, and the setup should include the required DLL's automatically. Once you build the setup project, you can install your application as a standalone software.
You usually distribute application with bunch of DLLs, that's nothing bad.
But if you really want to make it a single exe, you can look here - same question is answered Embed .net dll in c# .exe . (Valid if your DLLs are also .Net assemblies)
Edit: If you need to easily distribute app to not-very-computer-friendly users, consider also trying ClickOnce. It's roughly something like Java Web start - only disadvantage is that you can't get "Windows Logo" certificate from Microsoft for projects distributed that way.
I don't have Visual Studio 2010 to experiment with, but in Visual Studio 2019 this worked:
Project Properties->Configuration Properties->Advanced->Use of MFC->Use MFC in a Static Library
I'm kinda new to C# programming, and I'd like your help on something.
A quick review of what I have to do first.
I have to create : - A DLL that produces several .h5 files (HDF5 format) and one xml file
- A WPF viewer for the graphs that are written in these HDF5 files.
The problem is mainly that they are going to be used in a software called Panorama E², which basically manages DLLs, in a very restrictive way. For instance, it does not allow .NET framework 4 (Which makes me use the 3.5 version of the framework).
More info on Panorama : http://uk.codra.net/panorama/panorama-e2-information-system
I'm using HDF5DotNet.dll, that I compiled in x64 for .NET 3.5, and DynamicDataDisplay for my WPF application.
All my DLLs are going to be used by another computer, where Panorama is installed, and where Visual Studio isn't (only the 3.5 .NET framework and some required tools are).
What's the problem ?
Well, first, my WPF application isn't really one, Panorama doesn't seem to support WPF, only Windows Forms, and only as DLLs. Which means I created a WPF UserControl, that I embed in a Windows Form DLL.
I basically have 2 DLLs, one which is the WPF control, and one that uses this control in a winform. This is the last one that I have to integrate in Panorama. On my computer, the one I'm coding with, Panorama recognizes correctly the DLL and there's no problem.
But when I try to give these DLLs to my colleague, with his Panorama without Visual Studio installed, it doesn't work. After some tests, I noticed that it only works if the project (the DLLs) have been compiled on the same computer.
The same problem goes for the other DLL, the one that creates files. As I said, it uses HDF5DotNet.dll, but it seems it doesn't create it correctly. I guess it's the same problem, the DLL is not recognized.
What I tried.
I thought that maybe the DLLs weren't exported correctly. Maybe the referenced DLLs or assemblies aren't given, which are when you compile on the same computer. They're COM DLLs, because they're used in Panorama, and I can't manage to export them correctly.
I tried creating setup projects, so that they would be installed with their dependencies, but I couldn't find a way. Only the DLLs are installed. I tried looking at my DLLs with DependancyWalker, and there are some where dependancies are missing. Even if I try adding them manually, nothing changes.
I also know that regsvr32 doesn't work with .NET DLLs, because there is no entry point. That's why i thought about GAC, but I can't manage to register them (with strong name and everything), because I can't generate them directly.
So yeah, sorry for the long post, I tried to explain my train of thoughts and what I actually tried to do, but I can't find a way to give my projects to my colleague so that he can use them on his computer.
"Self Registration" ( be it RegSvr32, RegAsm or other ) is not a Windows Installer Best Practice. This injects out of process dependencies into the installation critical path that the installer is not aware of, that can fail and can't be rolled back or uninstalled.
The better approach is to use RegAsm /regfile to harvest the COM metadata for the ComVisible assembly and then author those registry values into your MSI's Registry table. This way Windows Installer merely has to copy the DLL and apply the registry values to register your component. It's far less likely to break and can be uninstalled and repaired cleanly.
How you do this exactly depends on the tool you are using to author your MSI. In WiX you'd use Heat to harvest this information. In InstallShield you'd set the .NET ComVisible attribute to True.
The end result is the same.
Hi try the following in command prompt instead of regsvr32 try the following :
"RegAsm.exe acxMaterialClassificationMerge.dll /codebase " where acxMaterialClassificationMerge.dll is your dll. You should do this on every pc thats going to use the dll. RegAsm is located in C:\Windows\Microsoft.NET\Framework\v2.0.50727
1: install first dotnet framework version 2 or newer on the computer
2: in command prompt :"RegAsm.exe acxMaterialClassificationMerge.dll /codebase " where acxMaterialClassificationMerge.dll is your dll. You should do this on every pc thats going to use the dll. RegAsm is located in C:\Windows\Microsoft.NET\Framework\v2.0.50727.
I am attempting to distribute a .NET Wizard form for Visual Studio, using a non-msi installer. For the sake of simplicity, let's focus on Visual Studio 2008.
So, as part of the post-build process of the assembly, I call:
regasm /regfile C:\path\to\my\assembly.dll
Then, pack the generated regfile and use regedit to merge this with the end users registry. I see that the assembly name and CLSID are generated properly and placed into HKEY_CLASSES_ROOT and HKEY_CLASSES_ROOT\CLSID, respectively.
However, on the Visual Studio side of things, after the installation is complete, I get an error. To elaborate, the Wizard is seen in the "Add New Items", via the vsdir file. This points to the vsz file, where Visual Studio sees the appropriate COM class. I can tell that it sees this class in HKEY_CLASSES_ROOT because the error message actually displays the correct CLSID:
Class not registered.
Looking for object with CLSID: {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
I am not entirely sure what the problem is. I know that the old InstallShield project had a simple check box for installing assemblies as COM interop. Unfortunately, this is not available to me. Perhaps that isn't really the problem and I am missing something from the Visual Studio 2008 installation side of things.
Any ideas or debugging help would be greatly appreciated. First and foremost, I want to verify that the assembly is correctly installed for COM interop. I have never used COM before, so it is all greek to me. :)
Edit: I should mention that this same assembly was build and distributed just fine with an "old" InstallShield project. Therefore, I know the problem lies within my own understanding/implementation of adding a .NET COM Wizard to the Visual Studio Add Items dialog.
Does your class (or assembly) have the Com visible attribute set to true?