system.dllnotfoundexception without VS 2008 - c#

My C# code loads a C++ DLL. It works fine on my PC, where Visual Studio 2008 is installed. But on other machines the program stop with an exception
Unhandeled exception: system.dllnotfoundexception unable to load dll ...
this application has failed becasue the application configuration is incorrect....
How can I make this code run on a machine that doesn't have VS 2008 installed?

You must distribute your DLL along with your project if it is a custom DLL of yours. If not, you must install the required DLL either with a custom installer or if it is from a different provider, a installer of them.
This post might be a bit older, but
DLL Files And .NET ClickOnce Deployment
I want to deploy one of my .NET apps as a ClickOnce application. The issue is that I am connecting to Oracle (see previous posts here and here). Connecting to Oracle requires at least, 4 DLL files that generally have to be in the same directory as the EXE file. The issue is that when the program is published, the DLLs are not referenced in any way, so the program won’t work.
Then I read about adding the files to the project, so that ClickOnce and the Publish processor will figure out that the DLLs are required and add them to the manifest.
Here is the process in Visual Studio 2005:
1. Put the 4 DLL files in their own directory in your solution directory (for ease of use mostly).
2. Add all four files to your project by going to “Project->Add Existing Item…”
3. Click on each DLL file in the solution explorer and then change their property: “Copy To Output Directory” to “Copy Always”.
That’s it! Now when I publish or even run the application I don’t have to worry about if the DLL files are where they should be.

in vs 2008 on project:
Properties>c/c++ >Runtime Library > choose: Multi-threaded Debug (/MTd)

Related

ActiViz.NET.x64 (v5.8.0): Unable to load DLL 'Kitware.VTK.vtkFiltering.Unmanaged.dll'

I'm trying to use the VTK with C# to read and write VTK/VTS files. I created a basic app, and I installed the 64-bit VTK .NET wrapper package which is called ActiViz.NET.x64 (v5.8.0).
The package installed without any problems, and I could access the Kitware.VTK namespace, but as soon as I try to create a VTK object, I got an unmanaged DLL loading error.
An unhandled exception of type 'System.DllNotFoundException' occurred in Kitware.VTK.dll
Additional information: Unable to load DLL 'Kitware.VTK.vtkFiltering.Unmanaged.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
I don't think that the exact code is relevant here, but I got the exception at the following line:
vtkStructuredGrid structuredGrid = vtkStructuredGrid.New();
I'm using Windows 10 x64, Visual Studio 2015, the target .NET Framework is 4.6.2 and I have ParaView 4.1 and 5.2 installed. The DLL in question is in the bin directory of the app, but I also tried to copy it to the Windows/System32 directory, the result is the same.
Is there a way to figure out what exactly the problem is with the dll loading?
If you go to the ActiViz product page you can see the following in the FAQ:
Does ActiViz 64 work with Visual Studio?
Visual Studio is a 32 bits
application, therefore 64 bits control does not work and you need the
32 bits version of ActiViz when using the designer within Visual
Studio. Usually, the 32 bits version is used to design and the 64 bits
version is used for the final compilation.
I also use VTK/ActiViz (C#) on Visual Studio, and it works fine when my program is targeting x86 platforms. However, if I target x64 platforms, the winforms control for the render window disappears, but I can still build the executable. So do this:
1) Install Activiz.NET.x86 from NuGet & target x86 platforms;
2) Create and debug your App;
3) Make a backup of the solution folder;
4) Install Activiz.NET.x64 from NuGet & target x64 platforms;
5) Don't open the designer because it will be buggy (all RenderWindowsControl disappear);
6) Build the solution (Release x64).
So, first I wanted to know where exactly is my process looking for the missing DLL. I used Sysinternals Suite and its Process Monitor.
I referenced VTK in my .NET library which I used in my self-hosted app. The self-hosted app was the start-up project, so the runtime looked for the missing DLL in the app's directory, not the library's, where it actually was.
After I copied the missing Kitware.VTK.vtkFiltering.Unmanaged.dll to that directory, Process Monitor confirmed that the DLL was read successfully, but I still got the same exception as before.
I compared the library's and the app's bin directories, and I figured that only the Kitware.mummy.Runtime.dll and Kitware.VTK.dll were copied there automatically.
I copied all the other VTK DLLs to the app's bin, and then it finally worked.
The exception's error message wasn't detailed in the first place, but I think it is more likely a problem with the ActiViz.NET package.
You should copy all dlls from Activiz Installation bin directory even you don't need to use in your code.
C:\Program Files (x86)\ActiViz.NET 5.8.0 OpenSource Edition\bin
Managed .Net DLL's is a wrapper for unmanaged VTK libraries. Mummy.dll is for this job.

How can I bundle the VC++ 2015 redistributable with my ClickOnce (.NET) application?

I have a C# application running on the .NET Framework 4.5 deployed via Microsoft ClickOnce. I also am utilizing a small utility from a Microsoft SDK called DComPerm.exe which is a C++ application that I had to compile separately. My main application uses Process.Start() to access this executable.
When I first tried running this on a client machine, I got an error message stating that VCRUNTIME140.dll was missing when the application tried to call DComPerm.exe.
This makes sense... since that program was compiled in C++ it needs the Visual C++ 2015 Redistributable package, which had not been installed on the client machine. I want to make this as painless as possible, so I was hoping I could bundle the VC++ 2015 Redist with my ClickOnce application. Under the project properties > Publish tab, there's a button for Prerequisites, which allows me to specify that the application should bundle the redistributable package.
That sounds great in theory, but it doesn't work. Now when I try to install my ClickOnce application on the client machine, it doesn't work. The installation fails and points me to a log file, which contains the following relevant information:
'Visual C++ "14" Runtime Libraries (x86)' RunCheck result: Install Needed
Installation of components 'Visual C++ "14" Runtime Libraries (x86)' was accepted.
Copying files to temporary directory "C:\Users\Owner\AppData\Local\Temp\VSD3872.tmp\"
Downloading files to "C:\Users\Owner\AppData\Local\Temp\VSD3872.tmp\"
(8/4/2016 12:57:48 PM) Downloading 'vcredist_x86\vcredist_x86.exe' from 'http://go.microsoft.com/fwlink/?LinkID=800028&clcid=0x409' to 'C:\Users\Owner\AppData\Local\Temp\VSD3872.tmp\'
Download completed at 8/4/2016 12:57:49 PM
Downloading failed with HRESULT=-2146697208
And that message makes it pretty clear what the problem is: the link that it's trying to use to download the redist package is dead. Only... I'm not sure how I can tell it to find the correct link. I'm quite surprised that it can't find it automagically as that seems like a bug with Visual Studio. Some searching revealed that the correct link is actually this one, but that's not what ClickOnce is resolving. I also saw that by checking the box this was the corresponding XML update to my csproj file:
<BootstrapperPackage Include="Microsoft.Visual.C++.14.0.x86">
<Visible>False</Visible>
<ProductName>Visual C++ "14" Runtime Libraries %28x86%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
Is there some XML tag I can use to specify the location explicitly? Or how else can I fix this? How can I bundle the redistributable without breaking my application?
I had pretty much the exact same problem. You asked how to specify the download location that ClickOnce resolves. In order to do that, open
C:\Program Files (x86)\Microsoft Visual Studio 14.0\SDK\Bootstrapper\Packages\vcredist_x86\en\package.xml
and edit the attribute with Name="https://go.microsoft.com/fwlink/..." to the correct URL. By the way, thanks for finding the correct download link, I hadn't been able to find it until seeing this post.
The VC++ Redis installed correctly on the client's computer after doing this.

Very slow app startup when using dll built with VS 2010

I have a class library project consisted purely of xml files with build action set to Embedded resource. Application reads these files during startup.
When I build this project inside VS 2010, deploy this project to IIS, application starts very slowly ( > 5 min).
When I open same solution with VS 2012, build class library project and deploy dll to IIS, application starts for ~20 seconds.
Inspection of both dll-s with ILSpy didn't find any differences. Also, dlls size is identical. This is profiler trace of slow startup:
Any ideas what could be the cause this issue?
Thanks.

Deploy a program that includes Microsoft.Smartdevice.Connectivity assembly

I am using Microsoft.Smartdevice.Connectivity assembly as a part of a larger application. Now I have to deploy that application and I can't find any info in regarding to deploying such applications. Even on the msdn resource page there is a question regarding this issue, with no replys.
So how can I deploy such an application. Is there a list of assemblys I have to deploy or something?
I have included the Misrosoft.Smartdevice.Connectivity.dll however the application is still missing at least one file: "Microsoft.VisualStudio.Connectivity.Interop.dll" I can't find that file anywhere. How can I deploy this application on a machine without visual studio installed.
How can I deploy the application on a computer without visual studio? Is there a SmartDevice Connectivity API redistributable or something?
Thank you for your help.
There is a tool called IsoStoreSpy.application. You can use it to deploy applications.
Good luck
This is a very old question but these libraries are in the NuGet package managerment framework which should allow you to include references. Set the project's build to copy all package-managed DLLs into the output directory of your executable.
http://www.nuget.org/packages/Smartdevice.Connectivity/

.net c# Winforms .exe wont start on any other machine

Ive developed a winforms application on my local machine using .net 4.0 and it runs fine. I have all dotnet versions installed.
When I copied the .exe and all of its references (the complete bin\debug and bin\release) to another machine it simply does not run. On one of my VMS it fires up visual studio express and asks if I want to connect a debgger. On other machines it just doesnt do anything.
But I can work out what on earth is going on.
I have referenced soem xceed dlls that are installed in GAC but not on the target machines GAC could this be the problem?
How do I tell what the hell is going on?
Pete
Yes, the xceed dlls (and every other referenced dlls) must exist on the target machine -- either included in the application directory or the GAC.
You may try specifying "Copy Local = true" to the suspect references, and rebuilding your project, so that these dlls are specifically included with the compiled assemblies.
if you deploy the pdb-files to the one VM with VS Express installed you should be able to connect the debugger and see the exception details. And yes, a missing assembly can (or better: will) cause that kind of behavior if the assembly is not only referenced but actually used in your application. I would generally recommend to implement some kind of error logging (either to the event logs or to a text file).
Have you checked that the other machine has a version of the .Net Framework installed? Failing that try to publish the application using the ClickOnce tool.
ClickOnce will download and instal any missing dependencies for the .Net Framework if necessary.

Categories