we're seeing an intermittent problem when we try to run a .Net 4.0 application on a remote computer via PsExec.
The target computer is Windows Server 2008 SP2 64-bit with .Net 4.0 and .Net 4.5 installed.
I've been told that this has been happening here since .Net 4.5 was installed, but I'm new to the project, so I can't confirm that this is when the problem started happening.
The code that is failing is doing this:
var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
return (ParameterData)config.GetSection("ParameterData");
Here's the stack trace:
System.Configuration.ConfigurationErrorsException: An error occurred loading a configuration file: Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED)) ---> System.Runtime.InteropServices.COMException: Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))
at System.Security.Policy.PEFileEvidenceFactory.GetLocationEvidence(SafePEFileHandle peFile, SecurityZone& zone, StringHandleOnStack retUrl)
at System.Security.Policy.PEFileEvidenceFactory.GenerateLocationEvidence()
at System.Security.Policy.PEFileEvidenceFactory.GenerateEvidence(Type evidenceType)
at System.Security.Policy.AssemblyEvidenceFactory.GenerateEvidence(Type evidenceType)
at System.Security.Policy.Evidence.GetHostEvidenceNoLock(Type type)
at System.Security.Policy.Evidence.GetHostEvidence(Type type, Boolean markDelayEvaluatedEvidenceUsed)
at System.Security.Policy.AppDomainEvidenceFactory.GenerateEvidence(Type evidenceType)
at System.Security.Policy.Evidence.GetHostEvidenceNoLock(Type type)
at System.Security.Policy.Evidence.RawEvidenceEnumerator.MoveNext()
at System.Security.Policy.Evidence.EvidenceEnumerator.MoveNext()
at System.Configuration.ClientConfigPaths.GetEvidenceInfo(AppDomain appDomain, String exePath, String& typeName)
at System.Configuration.ClientConfigPaths.GetTypeAndHashSuffix(AppDomain appDomain, String exePath)
at System.Configuration.ClientConfigPaths..ctor(String exePath, Boolean includeUserConfig)
at System.Configuration.ClientConfigurationHost.get_ConfigPaths()
at System.Configuration.ClientConfigurationHost.GetStreamName(String configPath)
at System.Configuration.BaseConfigurationRecord.InitConfigFromFile()
--- End of inner exception stack trace ---
at System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean ignoreLocal)
at System.Configuration.BaseConfigurationRecord.ThrowIfParseErrors(ConfigurationSchemaErrors schemaErrors)
at System.Configuration.Configuration..ctor(String locationSubPath, Type typeConfigHost, Object[] hostInitConfigurationParams)
at System.Configuration.ClientConfigurationHost.OpenExeConfiguration(ConfigurationFileMap fileMap, Boolean isMachine, ConfigurationUserLevel userLevel, String exePath)
at System.Configuration.ConfigurationManager.OpenExeConfigurationImpl(ConfigurationFileMap fileMap, Boolean isMachine, ConfigurationUserLevel userLevel, String exePath, Boolean preLoad)
at System.Configuration.ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel userLevel)
This is executed during our automated test build deployment process. I've been able to boil it down to a simple executable that does the code above, and I call PsExec from my Windows 7 development machine, but the problem's intermittent.
It seems to occur more regularly if I wait several minutes between invocations of PsExec. I started looking at this problem today, and was able to repro it pretty regularly in the morning, but not very easily in the afternoon.
I also see warnings like this in the Event Log:
Windows detected your registry file is still in use by other applications or services. The file will be unloaded now. The applications or services that hold your registry file may not function properly afterwards.
DETAIL -
1 user registry handles leaked from \Registry\User\mySID:
Process 5568 () has opened key \REGISTRY\USER\mySID
I don't know how the Event Log errors are related to the exception, if at all.
The PsExec command line is: PsExec /accepteula \\myServerName -d "path_to_exe"
I'm wondering if it's a problem with the user profile service, so I was thinking about not loading the profile when calling PsExec, but since it's so intermittent, I'm not sure how I would know if I've fixed it.
Searching the internet shows that some people think it might be related to impersonation, but nothing that directly matches my situation.
Has anyone seen anything like this? This is really weird.
Thanks!
Phil
if it works when run locally but not when run remotely there's a possibility:
When using PsExec the programs on the remote machine are limited to 150MB of memory
Running this on the remote machine will allow remote commands to use more than 150 MB of memory:
set-item wsman:localhost\Shell\MaxMemoryPerShellMB 2048
Related
I'm having some issues running the Emgu on my server. It runs fine locally, but when I try to use it on the server with IIS, it doesnt work.
Here is the error:
System.TypeInitializationException: The type initializer for 'Emgu.CV.CvInvoke' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'cvextern': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
at Emgu.CV.CvInvoke.RedirectError(CvErrorCallback errorHandler, IntPtr userdata, IntPtr prevUserdata)\r\n at Emgu.CV.CvInvoke..cctor()
--- End of inner exception stack trace ---
at Emgu.CV.CvInvoke.cvCreateImageHeader(Size size, IplDepth depth, Int32 channels)
at Emgu.CV.Image`2.AllocateData(Int32 rows, Int32 cols, Int32 numberOfChannels)
at Emgu.CV.Image`2.set_Bitmap(Bitmap value)
at VerifyID.Managers.ImageTreatmentsManager.ExtractDocumentFromImage(Bitmap bitmap)
at VerifyID.VerifyWorker.ExecuteOCR(BigIdRequest request, BigIdEvent bigIdEvent)
I have the following dlls inside the x86 and x64:
concrt140.dll*
liblept172.dll*
msvcp140.dll*
vcruntime140.dll*
cvextern.dll*
libtesseract304.dll*
opencv_ffmpeg320.dll*
IIS version: 10.0
After copying the x64 dlls directly to the bin directory of the build the error changed to:
System.TypeInitializationException: The type initializer for 'Emgu.CV.CvInvoke' threw an exception. ---> System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
at Emgu.CV.CvInvoke.RedirectError(CvErrorCallback errorHandler, IntPtr userdata, IntPtr prevUserdata)
at Emgu.CV.CvInvoke..cctor()
--- End of inner exception stack trace ---
at Emgu.CV.CvInvoke.cvCreateImageHeader(Size size, IplDepth depth, Int32 channels)
at Emgu.CV.Image`2.AllocateData(Int32 rows, Int32 cols, Int32 numberOfChannels)
at Emgu.CV.Image`2.set_Bitmap(Bitmap value)
at VerifyID.Managers.ImageTreatmentsManager.ExtractDocumentFromImage(Bitmap bitmap)
at VerifyID.VerifyWorker.ExecuteOCR(BigIdRequest request, BigIdEvent bigIdEvent)
Could someone help ?
I had this same problem, the application works perfectly on the local server (IIS Express used by the Visual Studio) but not on the remote Windows server, the solution that worked for me was:
(Please test your application between each step, maybe you don't need to do them all)
In Visual Studio, open your application project properties and set the "Platform" to "Any CPU". Then publish your application to the remote server.
Move all .dll files inside the x86 folder to the bin folder, pay special attention to the cvextern.dll, it must be inside the bin folder side by side with your application dll.
Install Visual C++ Redistributable for Visual Studio on the remote server (just google it and you will find the download link. Please choose the download version according to your VS version, 2013, 2015, 2017, 2020, 2050...). Use the x86 installation even if you sever OS is x64.
Activate your app_pool for the application for running 32 bit. https://help.webcontrolcenter.com/kb/a1114/how-to-enable-32-bit-application-pool-iis-7-dedicatedvps.aspx
Go to the application \bin folder, grant the file security for the folder "x86" (which contains all the dll for emgu) as described in the following link "http://www.iis.net/learn/manage/configuring-security/application-pool-identities if your apppool being in used in defaulapppool, then you should add user "IIS AppPool\DefaultAppPool"
I really don't know why the x64 versions of those dlls are not working on the server for me. I still investigating it and as soon I find out why I will update this post.
Another solution (that is not elegant at all, but works) is to install the Visual Studio at the server, doing the same installation process that you have done for your development environment. By doing this you will have all dependencies and dlls needed (including the Visual C++) installed on the server.
Hope it helps!
I have a machine with a clean install of Windows 7 where I want to install my app.
I've built a WPF App on Windows 10 with prerequisites of .NET 4.5 and Visual C++ Redistributable Packages for Visual Studio 2013
I've included them in my Clickonce installer as Prerequisites:
If I attempt to run the .application file that is generated from Clickonce on the Windows 7 machine, I get the following error:
Cannot Continue. The application is improperly formatted. Contact the
application vendor for assistance.
However, I run the setup.exe on my Windows 7 machine it correctly prompts that it needs to install .NET 4.5 and Visual C++ Redistributable Packages for Visual Studio 2013. It then successfully goes through the install process for each Prerequisite.
Except, after the Prerequisites are installed, I receive the same The application is improperly formatted. error from above.
If I then re-run the .application file it will finally install.
Either way, this is definitely not a good user experience. Is this something to do with building the App on Windows 10 and attempting to install on Windows 7?
I've seen this question which seems similar, however I am installing .NET 4.5 as a prerequisite:
Manifest may not be valid or the file could not be opened.
Below are the error details:
PLATFORM VERSION INFO
Windows : 6.1.7601.65536 (Win32NT)
Common Language Runtime : 2.0.50727.5420
System.Deployment.dll : 2.0.50727.5420 (Win7SP1.050727-5400)
mscorwks.dll : 2.0.50727.5420 (Win7SP1.050727-5400)
dfdll.dll : 2.0.50727.4927 (NetFXspW7.050727-4900)
dfshim.dll : 4.0.40305.0 (Main.040305-0000)
SOURCES
Deployment url : file:///C:/Users/BHS/Desktop/New%20folder/BHSScaleOps.application
ERROR SUMMARY
Below is a summary of the errors, details of these errors are listed later in the log.
* Activation of C:\Users\BHS\Desktop\New folder\BHSScaleOps.application resulted in exception. Following failure messages were detected:
+ Exception reading manifest from file:///C:/Users/BHS/Desktop/New%20folder/BHSScaleOps.application: the manifest may not be valid or the file could not be opened.
+ Manifest XML signature is not valid.
+ SignatureDescription could not be created for the signature algorithm supplied.
COMPONENT STORE TRANSACTION FAILURE SUMMARY
No transaction error was detected.
WARNINGS
There were no warnings during this operation.
OPERATION PROGRESS STATUS
* [3/21/2017 4:20:01 PM] : Activation of C:\Users\BHS\Desktop\New folder\BHSScaleOps.application has started.
ERROR DETAILS
Following errors were detected during this operation.
* [3/21/2017 4:20:01 PM] System.Deployment.Application.InvalidDeploymentException (ManifestParse)
- Exception reading manifest from file:///C:/Users/BHS/Desktop/New%20folder/BHSScaleOps.application: the manifest may not be valid or the file could not be opened.
- Source: System.Deployment
- Stack trace:
at System.Deployment.Application.ManifestReader.FromDocument(String localPath, ManifestType manifestType, Uri sourceUri)
at System.Deployment.Application.DownloadManager.DownloadDeploymentManifestDirectBypass(SubscriptionStore subStore, Uri& sourceUri, TempFile& tempFile, SubscriptionState& subState, IDownloadNotification notification, DownloadOptions options, ServerInformation& serverInformation)
at System.Deployment.Application.DownloadManager.DownloadDeploymentManifestBypass(SubscriptionStore subStore, Uri& sourceUri, TempFile& tempFile, SubscriptionState& subState, IDownloadNotification notification, DownloadOptions options)
at System.Deployment.Application.ApplicationActivator.PerformDeploymentActivation(Uri activationUri, Boolean isShortcut, String textualSubId, String deploymentProviderUrlFromExtension, BrowserSettings browserSettings, String& errorPageUrl)
at System.Deployment.Application.ApplicationActivator.ActivateDeploymentWorker(Object state)
--- Inner Exception ---
System.Deployment.Application.InvalidDeploymentException (SignatureValidation)
- Manifest XML signature is not valid.
- Source: System.Deployment
- Stack trace:
at System.Deployment.Application.Manifest.AssemblyManifest.ValidateSignature(Stream s)
at System.Deployment.Application.ManifestReader.FromDocument(String localPath, ManifestType manifestType, Uri sourceUri)
--- Inner Exception ---
System.Security.Cryptography.CryptographicException
- SignatureDescription could not be created for the signature algorithm supplied.
- Source: System.Security
- Stack trace:
at System.Security.Cryptography.Xml.SignedXml.CheckSignedInfo(AsymmetricAlgorithm key)
at System.Security.Cryptography.Xml.SignedXml.CheckSignatureReturningKey(AsymmetricAlgorithm& signingKey)
at System.Deployment.Internal.CodeSigning.SignedCmiManifest.Verify(CmiManifestVerifyFlags verifyFlags)
at System.Deployment.Application.Manifest.AssemblyManifest.ValidateSignature(Stream s)
COMPONENT STORE TRANSACTION DETAILS
No transaction information is available.
Your manifest is signed using SHA-256. When you try to install the ClickOnce application on a machine which has only .NET 4.0 installed you receive the Manifest XML signature is not valid error you mentioned because up to .NET 4.0 SHA-1 is expected.
This is why after you successfully installed .NET 4.5 as prerequisite everything works fine. I have no idea why this isn't working in a single step but requires two steps instead. Perhaps this relates to a restart required after installing the new framework version?
The solution is to use SHA-1 when signing your manifest. You can find information on how to achieve this in this answer from Miroslav Nedyalkov.
I'm having a problem using ClickOnce,
It is an online Clickonce.
My project is C# project built in Visual Studio 2013.
The application works on 99% of the machines , but there are few computers which it doesnt deploy containing the error:
Following errors were detected during this operation. * [16/08/2015
14:19:05] System.IO.FileNotFoundException
- The system cannot find the file specified. (Exception from HRESULT: 0x80070002)
- Source: mscorlib
- Stack trace: at System.Deployment.Internal.Isolation.IsolationInterop.CreateActContext(CreateActContextParameters&
Params) at
System.Deployment.Internal.Isolation.IsolationInterop.CreateActContext(IDefinitionAppId
AppId) at
System.ActivationContext.CreateFromName(ApplicationIdentity
applicationIdentity) at
System.ActivationContext.CreatePartialActivationContext(ApplicationIdentity
identity) at
System.Deployment.Application.ApplicationActivator.Activate(DefinitionAppId
appId, AssemblyManifest appManifest, String activationParameter,
Boolean useActivationParameter) at
System.Deployment.Application.ApplicationActivator.PerformDeploymentActivation(Uri
activationUri, Boolean isShortcut, String textualSubId, String
deploymentProviderUrlFromExtension, BrowserSettings browserSettings,
String& errorPageUrl) at
System.Deployment.Application.ApplicationActivator.ActivateDeploymentWorker(Object
state)
The error occur in the end of the installion, but I suppose it doesnt really install (there are some files in the appdata folder, but when I click the ClickOnce installer again, it reinstall it from 0)
I've done some research, and I got to the registry key :
HKEY_CURRENT_USER\Software\Classes\Software\Microsoft\Windows\CurrentVersion\Deployment\OnlineAppQuotaUsageEstimate
Which is the cache location for online Clickonce applications.
On the computers which works, after the installer the value change to 837207846
On the computers which the ClickOnce doesnt work, it changes to 0.
any suggestions how to fix that problem?
I have C# project in which I am using Microsoft.SqlServer.Management.Smo, Microsoft.SqlServer.batchparser.dll and few other SqlServer dlls.
When I run the code on development box it works fine, but when I try running the executable on a clean machine (client's machine), it fails and throws this exception:
Microsoft.SqlServer.Management.Smo.FailedOperationException: ExecuteNonQuery failed for Database 'testdb'. ---> System.IO.FileLoadException: Could not load file or assembly 'Microsoft.SqlServer.BatchParser.dll' or one of its dependencies. This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem. (Exception from HRESULT: 0x800736B1)
at System.Reflection.RuntimeAssembly.GetType(RuntimeAssembly assembly, String name, Boolean throwOnError, Boolean ignoreCase, ObjectHandleOnStack type)
at System.Reflection.RuntimeAssembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase)
at Microsoft.SqlServer.Management.Common.ServerConnection.GetStatements(String query, ExecutionTypes executionType, Int32& statementsToReverse)
at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(String sqlCommand, ExecutionTypes executionType)
at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(StringCollection sqlCommands, ExecutionTypes executionType)
at Microsoft.SqlServer.Management.Smo.ExecutionManager.ExecuteNonQuery(StringCollection queries, ExecutionTypes executionType)
at Microsoft.SqlServer.Management.Smo.Database.ExecuteNonQuery(StringCollection sqlCommands, ExecutionTypes executionType)
Now if I install "Microsoft SQL Server 2012 Shared Management Objects" on the client's machine it starts working.
I want to find out exactly what dependency is causing batchparser to fail. I grabbed the assemblies from the "Microsoft SQL Server 2012 Shared Management Objects" installer and copied them into GAC, but still the same error.
My questions are:
1 - How can I find the dependency of the batchparser.dll and append it to my installer?
2 - Is there a re distributable package for sql server 2012 that I can install before my application.
Thanks,
Ali
For anyone having the same problem,
Installing Microsoft Visual C++ Redistributable Package ATL Security Update fixed the problem for me.
Cheers,
This is a really odd situation, so hopefully I can explain it well enough.
I am deploying an ASP.NET 4 webforms application to a Windows Server 2003 SP2 server running IIS6.
Here's the problem -- when the application pool recycles its worker process (w3wp.exe), about 80% of the time, I will get an ReflectionTypeLoadException error trying to access any page in the app that contains an EntityDataSoure every time I try to view it.
However (this is the interesting part) -- the other 20%, it works just fine. I've actually resorted to turning off recycling the worker process entirely for this application pool and just add/remove whitespace from web.config forcing the site to recompile until I get a "good" w3wp.exe.
If this isn't clear, what I'm saying is: the actual worker process doesn't work at all for pages containing an EntityDataSource for about 4/5 times it starts, but still manages to serve all other pages just fine. Once you get a worker process that manages to serve a page with an EntityDataSource, it works every time until that process gets recycled.
My question is, how can I debug this? It works fine on my dev machine, it works fine on the server as long as you get a good process running, but iisreset or a server restart or anything that kills the worker process is almost guaranteed to cause the site to not come back up and throw this ReflectionTypeLoadException.
Here is the compilation section of my web.config:
<compilation debug="false" targetFramework="4.0">
<assemblies>
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
</assemblies>
</compilation>
Here is all the information I have about this exception:
Application information:
Application domain: /LM/W3SVC/1/Root/name-5-129230865053805490
Trust level: Full
Process information:
Process ID: 3300
Process name: w3wp.exe
Account name: NT AUTHORITY\NETWORK SERVICE
Exception information:
Exception type: ReflectionTypeLoadException
Exception message: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
Thread information:
Thread ID: 6
Thread account name: NT AUTHORITY\NETWORK SERVICE
Is impersonating: False
Stack trace: at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at System.Reflection.Assembly.GetTypes()
at System.Data.Metadata.Edm.ObjectItemConventionAssemblyLoader.LoadTypesFromAssembly()
at System.Data.Metadata.Edm.ObjectItemAssemblyLoader.Load()
at System.Data.Metadata.Edm.AssemblyCache.LoadAssembly(Assembly assembly, Boolean loadReferencedAssemblies, ObjectItemLoadingSessionData loadingData)
at System.Data.Metadata.Edm.AssemblyCache.LoadAssembly(Assembly assembly, Boolean loadReferencedAssemblies, KnownAssembliesSet knownAssemblies, EdmItemCollection edmItemCollection, Action`1 logLoadMessage, Object& loaderCookie, Dictionary`2& typesInLoading, List`1& errors)
at System.Data.Metadata.Edm.ObjectItemCollection.LoadAssemblyFromCache(ObjectItemCollection objectItemCollection, Assembly assembly, Boolean loadReferencedAssemblies, EdmItemCollection edmItemCollection, Action`1 logLoadMessage)
at System.Data.Metadata.Edm.ObjectItemCollection.ExplicitLoadFromAssembly(Assembly assembly, EdmItemCollection edmItemCollection, Action`1 logLoadMessage)
at System.Data.Metadata.Edm.MetadataWorkspace.ExplicitLoadFromAssembly(Assembly assembly, ObjectItemCollection collection, Action`1 logLoadMessage)
at System.Web.UI.WebControls.EntityDataSourceView.ConstructContext()
at System.Web.UI.WebControls.EntityDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments)
at System.Web.UI.WebControls.ListControl.OnDataBinding(EventArgs e)
at System.Web.UI.WebControls.ListControl.PerformSelect()
at System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound()
at System.Web.UI.WebControls.ListControl.OnPreRender(EventArgs e)
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
No changes are made to any files in the project, so I can't figure out why sometimes I get a "good" w3wp.exe and other times I get a "bad" w3wp.exe.
Check that you haven't got another ASP.NET site built against a lower version ( < 4.0 ) running in the same application pool. As with ASP.NET 1.1 and 2.0, ASP.NET 4.0 can't co-reside in the same worker process with other versions.
Update
I didn't catch the part of the exception that reports this because it was out of view:
Exception message: Unable to load one or more of the requested types.
Retrieve the LoaderExceptions property for more information.
^ ^ ^ look up, the framework is helping us for a change ^ ^ ^
Can you wrap a try/catch block around this in your code and dumpy the exceptions you find?
Something like the following code would do:
try
{
//Do your entity data thing in the page...
}
catch(ReflectionTypeLoadException rtle)
{
foreach(Exception ex in rtle.LoaderExceptions)
{
Debug.WriteLine(ex.ToString());
}
}
LoaderExceptions is a member of the ReflectionTypeLoadException exception being thrown and contains array of the exceptions being thrown by the class loader.
This should help you narrow things down, if not then post the list of exceptions you find in there.
Here's an update on this horrible bug -- I was deploying a reportviewer control and referencing a couple of the dlls required in my project with copy local = true. It seems that you have to install the ReportViewer redist on the server or you get funny behavior like this problem, which apparently had nothing to do with a EntityDataSource after all.
In short, I fixed this by installing the ReportViewer 10 redist on the server instead of just copying the dlls into bin.
http://www.microsoft.com/downloads/details.aspx?FamilyID=a941c6b2-64dd-4d03-9ca7-4017a0d164fd&displaylang=en
We had a similiar problem and solved it by making sure all projects which were referenced by the project giving the error had referenced the same versions of the dlls. i.e. project A was throwing this error, and project A referenced dll version 2. Project A also referenced project B, which itself referenced dll version 1. version 2 of the dll was being overwritten by version 1 from project B. As soon as the reference was changed in project b, project a worked like it should.