Why does my app require the full .NET 4 Framework? - winforms

I have a WinForms app targeting the .NET 4 Client Profile. However, when I try to run it on a machine that has only the Client Profile (and not the full/extended profile), I get ".NET Framework Initialization Error" saying I need to install ".NETFramework,Version=v4.0":
I've double-checked the project file to make sure that it is indeed targeting the client profile, and it is:
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
As are all of the projects it references. I'm not even sure where else to look - what is going on here?

Check your app.configs and verify the supported runtime specified in the startup:
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
</startup>
should be replaced with
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client" />
</startup>

Related

DevExpress DLL's License Exception in visual studio windows application due to CAS Policy

Exception occurred creating type 'DevExpress.XtraEditors.CheckEdit, DevExpress.XtraEditors.v8.2, Version=8.2.8.0, Culture=neutral, PublicKeyToken=9b171c9fd64da1d1' System.TypeInitializationException: The type initializer for 'DevExpress.Utils.AppearanceObject' threw an exception. ---> System.NotSupportedException: This method explicitly uses CAS policy, which has been obsoleted by the .NET Framework. In order to enable CAS policy for compatibility reasons, please use the NetFx40_LegacySecurityPolicy configuration switch. Please see http://go.microsoft.com/fwlink/?LinkID=155570 for more information. ..\Properties\licenses.licx
Tried below configuration in app.config to resolve the issue but did not work:
`
<configuration>
<runtime>
<NetFx40_LegacySecurityPolicy enabled="true"/>
</runtime>
<startup>
<supportedRuntime version="v3.5.0000"/>
<!--<supportedRuntime version="v1.0.3705"/>-->
</startup>
`
Is there any extra configuration or setup required to resolve this issue?
Tried the steps given in the link below to resolve the issue:
https://learn.microsoft.com/en-us/previous-versions/dotnet/netframework-4.0/dd409253(v=vs.100)
https://learn.microsoft.com/en-us/previous-versions/dotnet/netframework-4.0/w4atty68(v=vs.100)

BVN404 gadget showing in local dev, but not EpiServer integration enviornment

I am able to access this gadget in my local dev environment, but not integration, as you can see below:
Local dev:
Integration:
I double checked the BVN settings from here: https://github.com/Geta/404handler#configuration. They are setup like this in my web.config:
<section name="bvn404Handler" type="BVNetwork.NotFound.Configuration.Bvn404HandlerConfiguration, BVNetwork.EPi404" />
<episerver.shell>
<publicModules rootPath="~/modules/" autoDiscovery="Modules" />
<protectedModules rootPath="~/EPiServer/">
<add name="BVNetwork.404Handler" />
<bvn404Handler handlerMode="On">
<providers>
<add name="Custom Handler" type="CompanyName.Business.CustomPageNotFoundHandler, companyname-cms" />
</providers>
</bvn404Handler>
There is not a securedComponents section, though I did try to add one with allowedRoles="Administrator", allowedRoles="*", and allowedRoles="Everyone" for testing purposes.
Any ideas why the gadget can't be viewed when published?
The issue was that the BVN zip file did not publish to the modules folder for some reason. After adding it back, it worked as expected.
Nuget installations sometimes misses the protectedmodules section
Ensure the BVNetwork.404Handler is in your protectedModules collection in web.config. Nuget sometimes miss that.
<episerver.shell>
<protectedModules rootPath="~/EPiServer/"> <!-- this line may vary -->
<!-- other modules -->
<add name="BVNetwork.404Handler" />
</protectedModules>
</episerver.shell>

Error when running a .net core web app with React.js on IIS 10

I have a web app based on .net core v2.1 with a React.js front-end, which I'm trying to host on IIS 10. The app runs fine via Visual Studio (2017), however when I publish the app and host via IIS, I get the following error:
Error image
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
Error Code 0x8007000d
The web.config file was generated during the publish; I have not modified it:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\SkillsMatrix.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
</system.webServer>
</location>
</configuration>
<!--ProjectGuid: ea8a300c-5bb6-4a29-a8d2-d13dddbbac1d-->
This same error happens if I start a brand new project via VS, do not add any code, and publish it to IIS...
I have tried:
Giving access to the folder/file to the IIS_IUSRS user group
Removing app.UseHttpsRedirection(); in StartUp.cs
Does anyone have any suggestions for how I can clear this error and host my app?
You could try the below steps to resolve the issue:
1)Make sure you download and install the .net core hosting bundle and runtime.
https://dotnet.microsoft.com/download/dotnet-core/3.1
2)Make sure that the Application Pool > Process Model > Identity is set to ApplicationPoolIdentity or your custom identity has the correct permissions to access the application's deployment folder.
3)Set the application pool set the .NET CLR version to No Managed Code:
4)Confirm that you have enabled the proper server role. See IIS Configuration.
you could the below link for more detail:
https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/?view=aspnetcore-3.1

Turning off custom errors in Windows Service

I have a Windows Service that uses .NET Remoting (yes I know remoting has been replaced by WCF but this is a legacy application).
When I run the service I get this:
Exception Type: System.Runtime.Remoting.RemotingException Message:
Server encountered an internal error. For more information, turn off
customErrors in the server's .config file.
I have this in my application's config file:
<configuration>
<system.runtime.remoting>
<!-- other settings go here -->
<customErrors mode="Off" />
</system.runtime.remoting>
</configuration>
Oddly, I still get this exception. What am I doing wrong?

MissingMethodException when running application on different computer

I have a problem where I compiled my application on Visual Studio 2010 while targetting the .NET Framework 3.5, deployed it to a client server, only to find it gives me the following error:
************** Exception Text **************
System.MissingMethodException: Method not found: 'Void
System.Xml.Xsl.XslCompiledTransform.Transform(
System.Xml.XPath.IXPathNavigable,
System.Xml.Xsl.XsltArgumentList,
System.Xml.XmlWriter,
System.Xml.XmlResolver)'.
************** Loaded Assemblies **************
[...]
System.Xml
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3082 (QFE.050727-3000)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
The method it says it's looking for is this: XslTransform.Transform Method (IXPathNavigable, XsltArgumentList, XmlWriter, XmlResolver) (Supported in: 4, 3.5, 3.0, 2.0, 1.1)
I've tried setting up a redirect to the .NET Framework 4.0 version of the same DLL using the assemblyBinding element like so:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Xml"
publicKeyToken="b77a5c561934e089"
culture="neutral" />
<bindingRedirect oldVersion="2.0.0.0"
newVersion="4.0.0.0"/>
<codeBase version="4.0.0.0"
href="file:///C:/WINDOWS/Microsoft.NET/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll" />
</dependentAssembly>
</assemblyBinding>
</runtime>
But now the application won't run, and puts this in the event log:
EventType clr20r3, P1
myapplication.exe, P2 3.85.12.27583,
P3 4be9757f, P4 system.configuration,
P5 2.0.0.0, P6 4889de74, P7 1a6, P8
136, P9
ioibmurhynrxkw0zxkyrvfn0boyyufow, P10
NIL.
So, in summary, (1) does anyone know why the application can't find the method listed, and (2) why doesn't it let me redirect to the .NET 4.0 version of System.Xml?
Any help is appreciated, I'm totally stuck!
app.config as requested:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v2.0.50727"/>
</startup>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="myapplication.Properties.UserSettings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<system.net>
<mailSettings>
<smtp from="e-monitoring#myapplication.co.uk">
<network defaultCredentials="true" host="192.168.0.132" port="25" password="" userName="" />
</smtp>
</mailSettings>
</system.net>
<appSettings file="">
<add key="ReportDataCollectionTimeout" value="360" />
<add key="AllowedDatabaseBuild" value="3" />
<add key="AllowedDatabaseRevision" value="085" />
<add key="HelpNamespace" value="myapplicationHelpfile.chm" />
<add key="ProFormaHomePageUri" value="https://myapplication.co.uk/" />
<add key="ProFormaLoginPageUri" value="https://myapplication.co.uk/login.aspx" />
</appSettings>
<connectionStrings configSource="connectionStrings.config" />
<userSettings>
<myapplication.Properties.UserSettings>
<setting name="RequiresUpgrade" serializeAs="String">
<value>True</value>
</setting>
</myapplication.Properties.UserSettings>
</userSettings>
</configuration>
If you are targeting .NET 3.5 why are you doing a binding redirect to System.Xml v4.0.0.0? Make sure that your project references v2.0.0.0 of that assembly and that you have the following in your app.config:
<startup><supportedRuntime version="v2.0.50727"/></startup>
Also make sure that you are targeting .NET Framework 3.5 and not .NET Framework 3.5 Client Profile. Finally make sure the client has .NET 3.5 installed.
I've solved the problem by using this Transform method instead of the previous one (where I was previously passing null into the XmlResolver argument at the end).
Strange how this worked on my development and test machine, and not the server.
Try looking into the file version for System.XML.dll in the assembly folder. chances are that the last bit of the file on your system are different then the ones on server. in your case "2.0.50727.3082" does not seem to have the specified method signature. The version on the development machine was "2.0.50727.8009" which did have the required method signature.
EDIT: Decided to use the XMLReader version of the method. Even though we could register the newer version in the GAC(which did'nt give runtime error) from our local machine and that removed the error. but since the .NET could upgrade to a newer version and overwrite GAC we would need to be careful that the newer version would not have same problem.

Resources