Crash when running C# app with CPP\CLR on windows server 2012 - c#

I am using CLR to run a pre-compiled dll from C++ in a C# environment and experiencing differences between win server 2012 and win 7\win server 2008.
While in windows 7 or windows server 2008 the program works fine, but when trying to run in server 2012 I get:
"dll or one of its dependencies is not a valid win32 application"
Any known issues\solutions to this problem?
(OS is always 64, .net 4.5, VS 2013)
(Attached picture show the dll in Dependency walker under both OS)
Dependency walker on Windows server 2012
Dependency walker on Windows 7

You are missing the C++ run-time libraries on your server. Specificly, from the file name MSVCP100D.DLL I can tell that you need the debug version of the "Microsoft Visual C++ 2010 Redistributable", which is not allowed to be redestributed (as opposed to the release version which you can find here)
You can find the debug version of the run-time library inside the Visual Studio 2010 folder in the VC\redist\Debug_NonRedist folder. (Disclaimer: I don't have 2010 installed, but 2013 and 2015) As a workaround you can copy the missing dlls to the same folder you have your dll in.
To prevent having this problem in the future, either get a non-debug version of the DLL and install the public runtime redistributable or compile a static build (which includes those libraries in the DLL thus making it larger), debug or not.

Related

Visual Studio 2013: Build for Windows XP

I got a program made in Visual Studio 2013 (C#). I want to build it to XP. If I take the exe in the Debug directory and I run it on XP, I have an error "Is not a valid win32 application". What I have to do to build it for XP?
I got the solution: You got to right-click in the solution name on the Solution Explorer and go to Properties. In there, you can not only change the platform (x64 or x86) but the .NET Framework. I downgraded to .Net Framework 4 and worked perfectly!

How to log a project that is being deployed from Visual Studio?

I have a C# project written using Visual Studio Express 2013 for Windows Desktop. When I run the project in debug mode via Visual Studio (on Windows 8 Pro) it executes just fine, and so does copying the files out of the bin directory.
I need to deploy to a Windows 7 Embedded System with the correct version of .NET Framework. I tried:
copying the files over with the .dll and everythig from the bin folder and when starting I get no error, but doesn't start at all. I get no information at all.
tried the one click installer (choosing the option to install from dvd) and it seemed to install fine, but when I start it, I get same issue. Not starting, and no messages.
I also tried the Advanced Installer (free version) and when importing the visual studio project files it fails with the message "Failed to start Visual Studio. Error: Invalid Class String"
[UPDATE] Advanced Installer cannot import VS Express solutions because the API from VS that provides assistance on import is not available for VS Express edition. Only solutions created with paid editions of VS can be imported in Advanced Installer.
So how can I log or see what is happening to debug this?

CLR20r3 DirectoryNotFound in C# windows application Installer

I have developed a C# windows form application with Visual Studios 2010. it has a couple of external dependencies. It works fine when I run it from VS but fails on start up after I make an installer and try to run it. In the log files created by VS it gives me the following output.So basically there is something wrong with mscorlib.dll; even though I have this dll installed and referenced properly by the project.
<ProblemSignatures>
<EventType>CLR20r3</EventType>
<Parameter0>learningplatform.exe</Parameter0>
<Parameter1>1.0.0.0</Parameter1>
<Parameter2>515d6cf4</Parameter2>
<Parameter3>mscorlib</Parameter3>
<Parameter4>4.0.0.0</Parameter4>
<Parameter5>50484bd7</Parameter5>
<Parameter6>3fda</Parameter6>
<Parameter7>105</Parameter7>
<Parameter8>System.IO.DirectoryNotFound</Parameter8>
</ProblemSignatures>
Note : I am using .Net 4.0 on a 64-Bit Machine but Visual Studios version is 32 Bit(x86 platform).

ClickOnce Installer Prerequisites: How to auto-detect required version of Visual C++ Runtime

I have written a C# application that requires the Visual C++ 2010 redistributable to be installed, and I'm using the built-in "Publish" mechanism in Visual Studio to distribute the app -- which uses Microsoft's "ClickOnce" installer technology.
I discovered that I needed to click on the "Prerequisites" button on the Publish page, but there lies a problem.
Not knowing whether a user is x86 or 64-bit, I have to check box the x86 and x64 versions of the redistributable.
But if an x86 user installs it, they get an error: "Prerequisite check for system component Visual C++ 2010 Runtime Libraries (x64) failed with the following error message: "Installation of Visual C++ 2010 Runtime Libraries (x64) is supported only on x64 machines."
But if I don't include the x64 version, then 64-bit users can't user the installer.
Another issue is that some users get the error "A newer version of Microsoft Visual C++ 2010 Redistributable has been detected on the machine", and the installer fails.
This whole thing seems like a big mess. Isn't the ClickOnce installer tech smart enough to figure out whether the user needs the x86 or 64-bit version of the C++ redistributable? And if a newer version is installed, is that really a show stopper?
This all seems very brittle and it seems as though there should be a very simple fix for it.
ClickOnce is the actual deployment of the application, not the bootstrapper. Publishing a ClickOnce application will create a setup.exe that is a bootstrapper that installs the prerequisites for you. Your problem is with the prerequisite.
You can use the bootstrapper manifest generator (or notepad) to create the XML package information needed to make the C++ redistributable into a prerequisite package that you can select from the Visual Studio/Publish/Prerequisites dialog. I recommend you set up the prerequisite this way, and look at some of the other packages in the Bootstrapper folder (like SQLExpress) to see how they have done this.

Properties & methods missing in TLB generated out of a DLL via Visual Studio 2010

I have a C# class library project in Visual Studio 2010 to which I have added a Web Reference to the WSDL pointing it to my web service.
I can see that the proxies created in Visual Studio are fine. (see below screenshot)
Goal: My final goal is to be able to package and take these proxies to VBA (Excel 2010) and be able to call Web methods there.
I generated a TLB out of this DLL by enabling 'Make COM visible' and 'Register for COM Interop'.
Problem: When I open the TLB in Oleviewer, I see that the properties and methods are getting lost on the way (see below screenshots)
Environment:
Visual Studio 2010 Professional (Target platform set to x86)
Windows 7 x64
Office 2010 32-bit
.NET 4.0
Can someone help me know if I am missing something in generating a valid TLB from a DLL?

Categories

Resources