Configure Application to run on .NET 2.0 and 4.5 - vb.net

I am using Visual Basic Express 2010 and are trying to configure my application to run on a large variety of computers without the need of updating .NET Framework.
My current project has the following settings in app.config:
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
<supportedRuntime version="v4.0"/>
<supportedRuntime version="v2.0.50727"/>
The target framework is .NET 2.0. One may think that, with these settings, the program should run out of the box on machines with both .NET 2.0 and 4.X
However, when I attempt to run the software on a fresh Windows 8.1 virtual machine, I run into the following error:
I'd rather not have my users install .NET 3.5 if it's not necessary. Is there a way to get past this?
Thank you all in advanced.

Related

Visual Studio and msbuild produces .net 4 resources dlls instead of 3.5

If you follow the instructions on Access resx resource files from another project to create translations using resx files, when the project is .net 3.5 it is not working and it seems to ignore specified culture.
It seems that the problem is specific with my build chain.
I have installed
.net 4.8
Windows SDK 10 (I have this C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools)
Visual Studio 2019
When I inspect the output DLLs using jetbrain's dotPeek, I see that the satellite DLLs are .net 4.0
A colleague doesn't have .net 4.8 or Windows SDK 10 and he produces satellite DLLs .net 3.5
He has Windows SDK 7.
The problem AFAIK is with the al.exe that outputs these DLLs.
The problem was indeed with al.exe. The configuration in al.exe.config was specifying that it should support v4.0 of dotnet.
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0.30319"/>
</startup>
And by changing it to:
<startup>
<supportedRuntime version="v2.0.50727"/>
</startup>
solved it.

WCF Client error using 'Basic128Sha256Rsa15'

I get the following error when moving from using SHA1 to SHA256 encryption via my WCF client-side config file. This is for a .NET 3.5 client running on a Windows 2003 server.
I've implemented changes related to using SHA256 for SAML data found here
Snippet from my app.config:
<customBinding>
<binding name="HAServiceBrokerSOAP11BindingHewitt">
<security defaultAlgorithmSuite="Basic128Sha256Rsa15"
Error message I receive in client error log:
System.InvalidOperationException: The binding ('CustomBinding', 'http://tempuri.org/') has been configured with a security algorithm suite 'Basic128Sha256Rsa15' that is not supported
I finally got things working. I'll post my resolution in case others land here via a search.
One thing I tried that didn't work for me but may work for someone else is to use the Common Language Runtime version 4.0. CLR version 2.0 is what is used with .NET 3.5 assemblies. Here are the lines I added to my config file just after the element:
  <startup useLegacyV2RuntimeActivationPolicy="true">
        <supportedRuntime version="v4.0"/>
        <supportedRuntime version="v2.0.50727"/>
   </startup>
What finally worked for me was to upgrade the code from VS 2008 .NET 3.5 to VS 2010 .NET 4.0 and recompile the entire assembly. .NET 4.0 is not supported in VS 2008. .NET 4.0 assemblies use the CLR 4.0 version.

Application built with .NET 3.5 running on machine with only .NET 4.0. How does supportedRuntime element work?

We have an application that was built using .NET 3.5. There is a situation where it will run on a machine which only has .NET 4.0 installed.
If in the application configuration file the <supportedRuntime> element is not defined, or is defined as follows
<startup>
<supportedRuntime version="v2.0.50727"/>
</startup>
will the application crash on start up since .NET 3.5 and CLR v2.0.50727 are not present?
Note I understand that .NET 4.0 APIs are supposed to be compatible with .NET 3.5 ones and that a .NET 3.5 application should run in .NET 4.0. That is not the question. I am specifically asking about the <supportedRuntime> behavior.
Adding Hans Passant's comment as it seems a suitable answer.
The application will crash. To run on .NET 4.0 you need to add another supportedRuntime attribute with version="4.0".

Autocad 2010 and Framework 4.0

How can i assembly "NET Framework 4" with autocad 2010.
I have problems while using NETLOAD command.
You need to use .NET 3.5 with AutoCAD 2010. 4.0 is only supported by AutoCAD 2012.
AutoCAD 2010 can support non beta .Net 4.0 versions. If you edit the acad.exe.config file you may add this to get .Net 4.0 functionality:
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0"/>
</startup>
You can see for yourself in this AU material:
Using .NET 4.0 with AutoCAD
If you go into the AutoCAD install folder and edit the acad.exe.config file there you can add .NET 4.0 as a supported runtime:
<startup>
<!-- v Add this line v -->
<supportedRuntime version="v4.0"/>
</startup>
Note that advanced features of C# added in 4.0 wont work because they require all assemblies involved to be compiled for that version.
Go To Project>yourappname properties>Compile>Advanced Compile options. And choose target .NET Framework 3.5

How can I target .Net 4.0 Beta using NAnt?

I want to start testing my project using the Microsoft .Net 4.0 Beta version that has already been released. I know that adding a "net-4.0" target framework to NAnt requires updating nant.exe.config file, does anyone know what are the necessary changes?
If you want to use nant to build projects targeting .NET 4.0 you'll have to modify NAnt.exe.config and add the net-4.0 target framework and add a <supportedRuntime ... /> line to the <startup> section.
http://paigecsharp.blogspot.com/2009/08/nant-net-framework-40-configuration.html is a full code for .config file for NAnt.