无法启动程序C:\…\**.dll VB.net应用程序Visual Studio 2015
我已经在VB.net web应用程序上工作了一段时间,我不小心将“应用程序类型”设置从类库切换到了Windows窗体应用程序。我尝试构建,但失败了,但当我切换回时,程序将不再执行,显示错误: 无法启动程序“C:\Users\User\…\bin\Project.dll”无法启动程序C:\…\**.dll VB.net应用程序Visual Studio 2015,vb.net,visual-studio-2015,Vb.net,Visual Studio 2015,我已经在VB.net web应用程序上工作了一段时间,我不小心将“应用程序类型”设置从类库切换到了Windows窗体应用程序。我尝试构建,但失败了,但当我切换回时,程序将不再执行,显示错误: 无法启动程序“C:\Users\User\…\bin\Project.dll” “C:\Users\User\…\bin\Project.dll”不是有效的Win32应用程序 在此之前,应用程序将构建良好。 此外,在项目的属性页中,“Web”部分显示错误: 尝试加载页面时出错 值不在预期范围内 构建输出没有
“C:\Users\User\…\bin\Project.dll”不是有效的Win32应用程序 在此之前,应用程序将构建良好。 此外,在项目的属性页中,“Web”部分显示错误: 尝试加载页面时出错
值不在预期范围内 构建输出没有提供任何关于意外行为的线索,它构建得很好,只是不会运行。该代码也具有完整的功能 我尝试过多次重新启动,删除/bin目录并允许它从头开始重建(然后在失败时恢复旧内容),设置启动项目,更改目标CPU和调试/发布模式。我已经尝试过ReSharper构建和Visual Studio构建。 我还尝试了针对“C:\Users\User…\bin\Project.vshost.exe”的生成配置,但这将执行,然后立即关闭。 我没有选项在项目设置的应用程序页面中设置“启动对象”,但这从来都不是问题。我以前从未需要以EXE为目标来运行我的应用程序。若我尝试其他应用程序类型,它会声明“在项目中找不到Sub-Main” 我无法重新创建该项目,因为它的大小,所以如果有人能提供一些见解,我会喜欢它,下次我会注意不要玩弄IDE设置 =======更新=========== 因此,我通过将WebProjectProperties更改为:
<UseIIS>True</UseIIS>
<UseCustomServer>False</UseCustomServer>
<servers defaultServer="">
堆栈跟踪
[FileLoadException: Could not load file or assembly 'Microsoft.VisualStudio.QualityTools.UnitTestFramework (2)' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +36
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +152
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +77
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +21
System.Reflection.Assembly.Load(String assemblyString) +28
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +38
[ConfigurationErrorsException: Could not load file or assembly 'Microsoft.VisualStudio.QualityTools.UnitTestFramework (2)' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +738
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +217
System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +130
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +170
System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +92
System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +290
System.Web.Compilation.BuildManager.ExecutePreAppStart() +157
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +531
[HttpException (0x80004005): Could not load file or assembly 'Microsoft.VisualStudio.QualityTools.UnitTestFramework (2)' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9947380
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +261
好了,终于找到了解决办法,希望这能帮助其他可怜的灵魂,他们最终也会遇到同样的情况 第一步是编辑project.vbproj文件并更改:
<WebProjectProperties>
<UseIIS>False</UseIIS>
<UseCustomServer>True</UseCustomServer>
<servers defaultServer="SelfHostServer">
...
</servers>
</WebProjectProperties>
重新构建,一切正常
<WebProjectProperties>
<UseIIS>False</UseIIS>
<UseCustomServer>True</UseCustomServer>
<servers defaultServer="SelfHostServer">
...
</servers>
</WebProjectProperties>
<WebProjectProperties>
<UseIIS>True</UseIIS>
<UseCustomServer>False</UseCustomServer>
<servers defaultServer="">
...
</servers>
</WebProjectProperties>
Project.dll
Project.dll.CodeAnalysisLog.xml
Project.dll.config
Project.dll.CodeAnalysisLog
Project.pdb
Project.xml