0

I am getting the following exception when I try to run .NET 4.5 exe using Java (.NET 4.0 is installed on the machine

System.ComponentModel.Win32Exception: Thrown from .NET, original message: The specified executable is not a valid application for this OS platform.

Everything works fine if it's .NET 4.0 app. I've tried to set this attribute but still no luck.

  <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>

I don't have access to Java app so I can't debug it. Are there any obvious reasons for that?

MistyK
  • 6,055
  • 2
  • 42
  • 76
  • 2
    You say that .NET 4.0 is installed. Surely you need .NET 4.5 installed as well. A .NET 4.5 app is not going to run if you don't have .NET 4.5 installed. Or am I missing something. – RosieC Oct 30 '15 at 09:09
  • It will. That's why supportedRuntime is set. I can run this process on the machine with .net 4.0 installed using another C# app. – MistyK Oct 30 '15 at 09:11
  • But changing the SupportedRuntime surely won't help if the author of the app used features that are only available in .NET 4.5. In everything I've tried setting the SupportedRuntime only works if nothing in the app uses later features. – RosieC Oct 30 '15 at 09:14
  • Yes I can confirm. This app is not using any of .net 4.5 features – MistyK Oct 30 '15 at 09:17

1 Answers1

1

The issue might be that you are running a 64-bit app on a 32-bit machine or within a 32-bit Java VM, or the other way around. Also check if you have installed .NET 4.5 although I think the error message would be different then.

Make sure the application is built for 32-bits and that you run it from that Java VM.

Patrick Hofman
  • 153,850
  • 22
  • 249
  • 325
  • It doesn't look like this is a problem with 32/64bits. I set the project to be .NET 4.0 then I run it and it works. After that I am migrating to .NET 4.5 and get that exception. – MistyK Oct 30 '15 at 09:15
  • Look at this post: http://stackoverflow.com/questions/21566528/what-happens-if-i-remove-the-auto-added-supportedruntime-element It should work, at least it works if not run by JAVA – MistyK Oct 30 '15 at 09:34
  • I don't get it. If I remove this entry it means that you can run this project under current .NET framework installed if 4.5 is not present, isn't it? – MistyK Oct 30 '15 at 09:37
  • Yes but I've also tried to remove this entry which should allow to run under .NET 4.0, .NET 3.5, .NET 3.0 but may throw runtime exceptions if some of the .NET 4.5 features are used. – MistyK Oct 30 '15 at 09:39
  • .NET 4.5 – MistyK Oct 30 '15 at 09:42
  • Then that framework version has to be installed on the machine. – Patrick Hofman Oct 30 '15 at 09:42
  • Why am I able to run this app on my machine with .NET 4.0 installed if I remove this entry? – MistyK Oct 30 '15 at 09:43
  • Are you sure it hasn't .NET 4.5 installed? If Windows 10, it is. – Patrick Hofman Oct 30 '15 at 09:43
  • Windows Server 2003 - which is exactly the same OS that is used to run it with JAVA – MistyK Oct 30 '15 at 09:44
  • That platform isn't supported any more. For a long time already. – Patrick Hofman Oct 30 '15 at 09:44
  • Nevermind. Thank you for your help but the problem is either with the way java VM runs it or some other configuration which I am not aware of. – MistyK Oct 30 '15 at 09:45