.NET Framework version causing different behavior between two different machines? - c#

I'm currently trying to debug a weird issue I'm having with some RESTful API calls. I built an Angular 2 scaffold and used the publish feature to create a standalone build which users can run by opening a command prompt and typing in "project --debug" -> this will start the scaffold service and users can submit API calls to retrieve data from files. This works perfectly fine on my machine and I can make the API calls just fine, but I have another computer where the results are different. The other computer always fails and lands in an Exception block when accessing a specific type of file.
I'm wondering if this may have to do with some kind of version mismatch/difference on the .NET Frameworks and/or Microsoft Visual C++ redistributables. The published build (original computer) was built using .NET 4.5.1 while the other computer only has 4.6.1 installed.
Has anyone encountered a similar situation where the exact same build yields different results? I'm currently uninstalling versions of .NET and redistributables to test this hunch out but I'm curious if some of you may have had a similar experience.

Seems like my issue is related to the Microsoft Visual C++ 2015 Redistributables - I removed the 2015 redistributables from the original machine (because it turns on the other machine did not have them), and I received the same results. Going deeper, I'm guessing this is because one of the DLLs was built using the 2015 redistributables.

Related

MS Graph-Api on Windows Server 2016 in seperate AppDomain System.TypeLoadException

Just getting straight to the point and describe the Environment:
On-Premise Windows 2016 Server (datacenter edition)
All Frameworks (.net Core / .net 4.8 Full, etc) installed
Windows-Service running plugins in seperate App-Domain (One by Plugin)
Issue
When loading the faulty plugin following Exception occures (Stripped because of german environment):
TypeName: "Windows.Security.Authentication.Web.Core.FindAllAccountsResult", Type: "System.TypeLoadException"
Observations
On every developers machine everything runs perfect.
On a Windows-Server 2019 it runs perfectly in the same setup.
The file is present in %Windows%\System32-Folder
What i tried
Compiled as x86 and x64 - No difference
Added Nuget-references manually
Installed Windows-10-sdk on Server
Remote-Debugging without any more insights
Conclusion
Im still missing some components since everything works on Server 2019
Also i cannot do an inplace-Upgrade, neither can i use a different server
See used references here
Question
What am i missing? Any help is highly welcome.

C# application report with msvcp120_clr0400.dll [duplicate]

I just installed Visual Studio 2015 Community on my computer. Until now I have been using Visual Studio 2010 Professional. Now when I try to run my MVC apps in the build in web server, I get the following error message.
The procedure entry point __CrtGetFileInformationByHandleEx could not be located in \WINDOWS\SYSTEM32\msvcp120_clr0400.dll
I get the same error message if I try to execute vbc.exe (the Visual Basic compiler) on directly at the command prompt. My MVC app also shows a YSOD with
Compilation Error - Compiler Error Message: The compiler failed with error code -1073741511.
How can I fix my VS so I can run my programs again?!
Steps I've tried
Uninstall VS 2015 Community
Uninstall and reinstall .NET 4.6 and .NET 4.5.2
DISM /Online /Cleanup-Image /RestoreHealth
The .NET Repair Tool
Run sfc /scannow
Manually rename the msvcr120_clr0400.dll file to msvcr120_clr0400.dll.corrupt and do 1-5
Uninstall and reinstall VS 2010 w/ SP1
sfc /scannow successfully replaced the msvcr120_clr0400.dll file, but it replaced it with the exact same CTP file as before!
EDIT:
The problem dll's from my system are available for download here:
32 bit
64 bit
32 bit msvcr
64 bit msvcr
Microsoft is aware of this issue with KB3098779 and 3097997:
https://support.microsoft.com/en-us/kb/3118750
The recommendation is to uninstall these patches and then rescan for updates. Newer versions of these security patches (that do not break the VB compiler) are now available.
Okay, I see it from the files you uploaded to the sharing service, your .NET install is corrupted. A standard DLL Hell problem, your c:\windows\syswow64\msvcr120_clr400.dll file is the wrong version. Something you can see when you use Explorer and navigate to the file. Right-click and select Properties, look at the Details tab.
Note the word "CTP" in the Product name, means "Community Technology Preview". A Microsoft term that means "beta version". Clearly you should not be having the VS2013 beta on your machine. Your msvcp120_clr0400.dll is correct, it is file version 12.0.52512.0. It depends on an exported function in the msvcr DLL that the CTP version did not yet have.
Exactly how this happened is always hard to reverse-engineer. You are the 3rd SO user that I know of that had this problem this week, a bit too much of a coincidence. Two basic scenarios, if you ever had the VS2013 CTP edition installed on the machine then the problem is that it didn't get updated like it should have. Otherwise a very typical problem with CTP editions, they are pretty dangerous because the uninstaller is always the last thing Microsoft gets right. And the problem was just never detected until you started using a program that required this export.
Or it was caused by a rogue installer, copying the old version onto your machine without checking the version number. Much less likely, installers never have a good reason to install this particular file since it is only ever used by the .NET Framework. My money is therefore on your machine getting corrupted by the CTP.
You need to solve this by getting your machine fixed. Not that easy, you can never be sure how many other bad DLLs are lying around from such a bad CTP uninstall. A shortcut is copying this particular DLL from a good machine. But best to get .NET 4.6 re-installed.
EDIT from OP:
This answer correctly identified the problem files but reinstalling (or any other common steps) didn't solve it. In the end I copied "good" files from another computer with the version number 12.0.20806.33440.
KB3098779 appears to be the culprit on our server. That is the patch that installed the rogue CTP msvcr120_clr0400.dll mentioned in the above answer.
Solution: we reversed out the patch set that applied KB3098779, and everything is working again.
FYI: this is a .NET framework 4+ issue, not Visual Studio. Our server is a standard 2012 IIS server: Visual Studio is not installed.
I had the same issue on Windows 8.1 although KB3098779 and 3097997 were not installed on my machine. Probably it happened after installation of ASP.Net 5.
The issue was that I had both mcvcr files in version 12.0.51670.34230 while mcvcp files were already in 12.00.52512.0. It was enough to copy both mcvcr files (from System32 and SysWOW64) in this version from my colleague's pc.
If you have problems with permissions set to TrustedInstaller on these file, you can run this powershell command and then change permissions as Administrator:
takeown /A /F C:\windows\syswow64\msvcr120_clr0400.dll
Microsoft have issued a notice on this.
https://support.microsoft.com/en-us/kb/3118750
As others have pointed out too many people in too short a time to be a coincidence. Not a VS issue, this is to do with a bad update from Microsoft.
The info from MS mentions two security patches (KB3098779 and KB3097997).
I have uninstalled only KB3098779 and my site is up was up and running. It required a machine restart to complete
KB3097997 uninstalled without a restart. I maybe didn't need to uninstall but seems sensible given it is also subject to the same notice from MS.

C# .net 4 dependency

I have a standalone tool developed in C# Visual Studio Express 2010.
My problem is that this tool will fail to start on machines having no .NET installed, and asking for .NET 4 on machines has .NET under 3.5 or lower.
What I basically want to do is to install .NET 4 from my application before the main script runs. I can write a program to download it from an official webpage, also to run the installer etc. But the main problem still exists, the app won't even reach the download part as it won't run on machines...
I've googled around and found that you can include dll-s etc., but I still doubt I can proceed without a proper .NET installation. So how can run dotnetfx.exe with my .NET dependent application?
Your attention and ideas are much appreciated.
Cs.
Use ClickOnce - it takes care of dependencies when configured correctly and comes integrated/free with VS.
EDIT: So vs express editions don't support setup projects. Plan B: wix.
simple. your installer must not be a .net application. just write your own c++ version or use some existing application. here is a link to show you how to do silent installs of .net 4. just include the setup application with your program. I would be very surprised if some of the msi installer tools out there do not have .net installation support.
http://blogs.msdn.com/b/astebner/archive/2009/04/16/9553804.aspx

C# application crashes before start

I come to you because I'm desperate. I've developed a GTK# application in C# with the latest MonoDevelop. It's built for .NET framework 4.0 / x86, and the only external library it uses is the official Mysql .Net connector. It's meant to run under Windows XP.
It's the first application I make with this IDE. I was very happy with the results and the development time, but the deployment is a real headache.
It works perfectly on the development machine. The debug is clean. Everything's okay.
Then, as I couldn't find any information about the deployment, I installed a clean XP to try it and see what do I should install on the client's machine.
I've installed the SP3, .NET 4.0 and copied the release package with all the DLLs mentioned in the build log (that made it work outside the MonoDevelop in the development machine). But I'm getting a "the application has encountered a problem and needs to close" error, with no exception, in kernel32.dll, offset 0012aeb.
I've tried to install the .NET 3.5 before the 4.0, updated IE (just in case...), copied more GTK# and Monodevelop DLLs to the exe's folder, installed the Mysql .NET connector, installed Mono 2.8... But nothing. Still getting that unexplained error.
Google and StackOverflow searches didn't help me. I've researched and tried a lot of things in the last twelve hours or more without moving from this machine.
Do you have any advice? What can be causing it? Is there any way to debug the exe (without installing VS...)? Does anyone know what are all the dependencies of this kind of executable?
WinDbg can help you figuring some JIT trouble...
Even though it aint intuitive and require skills, Worth a try. might pop something up.
If it's meant to run under Windows, then you should probably compile it with the Visual C# compiler.
However, more related to your problem - get a debugger in your deployment machine and run the application on it. This is the best way to figure out the problem because we really can't guess it.
Mono Application Deployment Guidelines
There are several options to installing Visual Studio on your production machine, one of them is the Remote Debugging Monitor. It does not require a Visual Studio installation. You can copy the files from your development machine to your server. I've got them under C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Remote Debugger.
You can also use it for Remote Debugging of a Project Built Locally.

Porting ASP.NET application to Mono/Apache under Linux

I've got a relatively small ASP.NET project that was written using C# 4.0.
I was wondering if anybody had managed to port such a project over to running under a webserver on Linux, the latest information I can find appears to only have support for ASP.Net 2.0 - Configuring and running Mono ASP.NET 3.5 (AJAX.NET) on Linux computers
The project uses LINQ-to-SQL for the entire data access layer, and I know Mono itself support LINQ, so I thought it stands to reason that it should work.
I just want to know if it's a complete waste of time or not before starting.
Thanks.
I run an ASP.NET 4.0 application on Suse Linux using mono. My experience with mono is that it just works. My app is ~ 15.000 LOC and uses third party components like mongo-csharp-driver, lucene.net, elmah, munq, and sphorium.webdavserver.
I've had almost no compatibility problems during development - and the ones I had where easily worked out (for example sphorium accesses the registry; this obviously works different on Linux/Mono). I've even started developing with Visual Studio instaed of MonoDevelop and without the Mono plugin, because Visual Studio is a better IDE, and it just works when I compile my web app on linux and deploy it on Apache (even though I develop with .NET on Windows).
I've written a short blogpost on getting started with the setup
This is definitely not a waste of time. The company I work for converted our VB.Net application to C# so that it can run under mono. This application has over 200k lines of code. We now are running with Ubuntu/Apache/Mono/Postgresql on Amazon ec2.
The only concern I would have is with your database. If it is MS SQL then you will need to look at migrating to MySQL or Postgresql. Again we did this with 300+ tables and 900 stored procedures. It is definately something worthwhile in the long run.
I think that the best way to get started would be to setup a local environment running something like Ubuntu. You can get the near latest versions of mono from the repositories at http://badgerports.org/ or if you prefer you can the latest versions as build scripts which are maintained here. Install monodevelop and build your code on linux with mono. From experience the mono with C# is a pretty much a complete implementation of the .net framework. I would be surprised if there was something in your application that is yet to be implemented in mono.
I have an answer here showing an easy configuration for your application under apache. I use this configuration for mono applications running on Ubuntu.

Categories