CodeCop and .NET 4.6 - why won't it run? - c#

I have recently tried Code Cop 1.3.1 - a method interceptor.
However won't run when .NET Framework 4.6 is installed.

The solution to this is to use the following runtime element set your app.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
</startup>
<runtime>
<useLegacyJit enabled="1" />
</runtime>
</configuration>

Related

How can I change the run-time version and sku of .net framework to 2.0?

My application runs only on .NET 2.0.
But, I had the following text in App.config in the deployed application:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="assemblies"
type="Simple.Framework.AssembliesConfigurationSection, Simple.Framework"/>
</configSections>
<connectionStrings>
<add name="SystemSqlServer"
connectionString="Data Source=.\sqlexpress;Initial Catalog=gre;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
<startup>
<supportedRuntime version="v4.0"
sku=".NETFramework,Version=v4.5"/>
</startup>
</configuration>
I replaced the supportedRuntime with the following text, as my application took a long time to start:
<supportedRuntime version="v2.0"
sku=".NETFramework,Version=v2.0"/>
But, I am getting the following message:
The following picture shows that .NET 2.0 is already installed:
and, my .net 3.5.1 is already turned on, and there is no additional option for .net 2.0.

Multi-targeting .NET application

I want to write an application that run on windows 7 , 8 , 8.1 and 10 so I targeted 3.5 .NET framework on visual studio ( application name > build > Target framework > Select ".NET Framework 3.5" ) which as far as I know it's the version that windows 7 is shipped with by default (correct me if not) .
after that I added 2 entries to app.config file in visual studio so the whole file became like the following :
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0"/>
<supportedRuntime version="v2.0.50727"/>
</startup>
</configuration>
now is this enough to have my application working on windows 7 and later ? if not enough , how I can achieve this ? I viewed all stack overflow "Similar Questions" but nothing helped
EDIT : I don't want the user to be prompted with .NET download dialog if the .Net framework not found.
It should be enough to make your application run on any computer where either the .NET Framework 4 or the .NET Framework 3.5 is installed.
<supportedRuntime version="v4.0" /> make the application prefer .NET Framework 4.0 if it is installed and <supportedRuntime version="v2.0.50727" /> makes sure that you still support users with only .NET Framework 3.5 installed. You should change the order if you want the application to prefer 3.5:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v2.0.50727"/>
<supportedRuntime version="v4.0"/>
</startup>
</configuration>

Application configuration is invalid - application won't start

I had configuration warning in app.config of my wpf application.
my entire app.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns="schema URL">
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
I tried :
How to remove warning 'The 'configuration' element is not declared.' Visual Studio C#
and
The configuration element is not declared
and as stated in one of answers, tried to restart VS and start again. No luck
The configuration warning is gone, however the application can't start
Use this App.config file :
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>

How to move I18n folders of WPF application

When building my WPF application all internationalization/locale folders are put inside the folder of the executable.
/MyApp
/MyApp/de
/MyApp/fr
/MyApp/otherSpecialFolder
/MyApp/...
The problem is that this mixes up with some other folders. Is it possible to put the internationalization into a separate folder and let the Wpf app search there instead? For example:
/MyApp
/MyApp/i18n/de
/MyApp/i18n/fr
/MyApp/otherSpecialFolder
/MyApp/...
This problem occurs not only for own localization ressources but also when adding thirdparty controls like Xceed.Wpf.AvalonDock.
Yes you can. You just have to add probing element into your App.config.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="i18n"/>
</assemblyBinding>
</runtime>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
probing element specifies the path where assemblies are searched for.

How explicit is it advisable to be in App.config re: .NET runtime versions?

A little knowledge can be a dangerous thing.
Now that I've had a "run in" with depending on various .NET runtimes being installed on a user's machine, I want to be as "safe" and code as defensively as possible.
However, if I add this to my App.config file:
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v1.0.3705"/>
<supportedRuntime version="v1.1.4322"/>
<supportedRuntime version="v2.0.50727"/>
<supportedRuntime version="v3.0"/>
<supportedRuntime version="v3.5"/>
<supportedRuntime version="v4.0"/>
<supportedRuntime version="v4.0.30319"/>
</startup>
...is it tantamount to wearing suspenders, a belt, AND a cat suit?
(I'm targeting .NET 4 "standard")
No, but are you really using zero features of .NET 2.0+?
Um... There is no 3.0 or 3.5. Just 2.0.xxx and then there is v4.0
Have a look at this msdn link. In particula the first graphic
.NET Framework Versions and Dependencies

Categories