Website hosted on IIS contains multiple AssemblyFileVersionAttribute, what causes an error when calling FrameworkDescription property

If host a site (asp net framework 4.8) on IIS (win server 2019), then System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription
property call - throws an exception:
AmbiguousMatchException: Multiple custom attributes of the same type found.
If you try to get the attribute manually, then you can see that there are really two of them
Windows Server 2019
Internet Information Services
ASP.NET
-
Lex Li (Microsoft) 3,476 Reputation points
2023-05-17T05:35:30.8566667+00:00 I cannot reproduce this on a Windows 11 machine, and don't have a Windows Server 2019 machine at hand. Can you analyze the properties of
typeof(object).GetTypeInfo().Assembly
? That should reveal enough information on what might be wrong. -
-
TengFeiXie-MSFT 251 Reputation points • Microsoft Vendor
2023-05-17T09:01:20.0333333+00:00 I've seen discussions about this error before, about Application Insights. It looks like updating or uninstall the application insights extension. https://github.com/Azure/autorest/issues/1542#issuecomment-355260609
-
Alexey Gr 1 Reputation point
2023-05-17T10:00:52.2466667+00:00 TengFeiXie, i do not use Application Insights, and never used. Also I didn't find any follow installation on the server or in the project packages.
-
Lex Li (Microsoft) 3,476 Reputation points
2023-05-17T20:42:41.8+00:00 It's interesting to see the mscorlib file on my Windows 11 machine has only 36 custom attributes, while the copy on this server has 41. That might explain why you saw duplicate assembly file version attributes and experienced the problem. I think I will try to get a Windows Server 2019 machine and test again.
-
TengFeiXie-MSFT 251 Reputation points • Microsoft Vendor
2023-05-18T07:48:30.2866667+00:00 I created a new Windows server 2019 virtual machine. And created a new web api project to deploy to local IIS. I try to get the attribute manually, only one AssemblyFileVersionAttribute here, screenshot below. I can't reproduce the problem in windows server 2019, you can recreate a project and test if the same problem occurs.
-
Alexey Gr 1 Reputation point
2023-05-18T07:58:53.7233333+00:00 TengFeiXie, thanks for trying. i created a clean test project https://github.com/alexeygritsenko/GrpcTest to check for this error, I call the route http://grpctestnet48webapi.localhost:81/api/Test2 on IIS. The error appears on win server 2019, but on my other two machines (win server 2012, win 10) it works. Therefore, the point is not how to create a project, but in the environment. I don't know what to do with this. I successfully hosted other sites based net framework 4.8 on this server. All sites work, except when I need to call
System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription
property -
TengFeiXie-MSFT 251 Reputation points • Microsoft Vendor
2023-05-19T02:19:04.2533333+00:00 Ok, I get your idea. Can you provide the web.config setting of your application pool? Since you only get this error when calling the System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription property. Please check your assemblyfile, according to your screenshot, you should see two different versions of AssemblyFileVersionAttribute. Then delete the version 1.2.0.999. Starting with the .NET Framework 4, the default location for the Global Assembly Cache is %windir%\Microsoft.NET\assembly. In earlier versions of the .NET Framework, the default location is %windir%\assembly. Global Assembly Cache.
-
Alexey Gr 1 Reputation point
2023-05-22T08:16:52.9133333+00:00 TengFeiXie, in order
- configs and main dll https://1drv.ms/u/s!Aq6ZQkyoPcuMgaN-weZft0RpFFPRQA?e=TSDt5N
- which assembly file do you mean? in the first paragraph I archived
GrpcTest.Net48WebApi.dll
but its attributes looks ok - you told me to remove version 1.2.0.999. But in the control panel there is no such program to uninstall
-
Lex Li (Microsoft) 3,476 Reputation points
2023-05-23T00:01:20.6666667+00:00 At this moment, you might try to open the Properties dialog for
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\mscorlib.dll
and verify if underDigital Signatures
tab this file presents a valid signature. If the file was unexpectedly modified, the signature should be broken and you need a security professional to assist. -
-
Alexey Gr 1 Reputation point
2023-05-23T06:10:43.02+00:00 del duplicate message
-
TengFeiXie-MSFT 251 Reputation points • Microsoft Vendor
2023-05-24T10:09:03.88+00:00 According to my test and your test project, you should check your local environment. The assembly file is what I mentioned Global Assembly Cache. Check the local files of your Windows server 2019 through the link, and compare it with win 10. In addition, you can try to add <GenerateAssemblyInfo>false</GenerateAssemblyInfo> to your project to test whether it works: https://stackoverflow.com/a/55552285/20058276. I'm not sure it works. The problem lies in your win server 2019 environment. I can't reproduce your problem on my virtual machine.
Sign in to comment