无法启动程序C:\ ... \ ****。dll VB.net应用程序Visual Studio 2015

时间:2016-04-27 02:13:23

标签: vb.net visual-studio-2015

我已经在VB.net网络应用程序上工作了一段时间,我不小心切换了#34;应用程序类型"从类库设置到Windows窗体应用程序。我尝试构建,这失败了,但当我切换回来时,程序将不再执行,显示错误:

  

无法启动程序' C:\ Users \ User \ ... \ bin \ Project.dll'
  ' C:\用户\用户\ ... \ 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="">

但是现在当我运行程序时,会显示以下错误:

  

无法加载文件或程序集   &#39; Microsoft.VisualStudio.QualityTools.UnitTestFramework(2)&#39;或者其中之一   它的依赖关系。定位程序集的清单定义没有   匹配程序集引用。 (HRESULT异常:0x80131040)

     

System.IO.FileLoadException:无法加载文件或程序集   &#39; Microsoft.VisualStudio.QualityTools.UnitTestFramework(2)&#39;或者其中之一   它的依赖关系。定位程序集的清单定义没有   匹配程序集引用。 (HRESULT异常:0x80131040)

堆栈跟踪和详细信息:

=== Pre-bind state information ===
LOG: DisplayName = Microsoft.VisualStudio.QualityTools.UnitTestFramework (2)
 (Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: Microsoft.VisualStudio.QualityTools.UnitTestFramework (2) | Domain ID: 2
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/Users/User/Source/Repos/Findem/IfitConsulting/
LOG: Initial PrivatePath = C:\Users\User\Source\Repos\Findem\IfitConsulting\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\User\Source\Repos\Findem\IfitConsulting\web.config
LOG: Using host configuration file: C:\Users\User\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/0ef61219/b7128029/Microsoft.VisualStudio.QualityTools.UnitTestFramework (2).DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/0ef61219/b7128029/Microsoft.VisualStudio.QualityTools.UnitTestFramework (2)/Microsoft.VisualStudio.QualityTools.UnitTestFramework (2).DLL.
LOG: Attempting download of new URL file:///C:/Users/User/Source/Repos/Findem/IfitConsulting/bin/Microsoft.VisualStudio.QualityTools.UnitTestFramework (2).DLL.
WRN: Comparing the assembly name resulted in the mismatch: NAME
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

堆栈跟踪

[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

1 个答案:

答案 0 :(得分:1)

好的,所以终于想出了如何解决它,希望这可以帮助其他一些在同样情况下最终的穷人!

第一步是编辑project.vbproj文件并更改:

        <WebProjectProperties>
      <UseIIS>False</UseIIS>
      <UseCustomServer>True</UseCustomServer>
      <servers defaultServer="SelfHostServer">
        ...
      </servers>
    </WebProjectProperties>

        <WebProjectProperties>
      <UseIIS>True</UseIIS>
      <UseCustomServer>False</UseCustomServer>
      <servers defaultServer="">
        ...
      </servers>
    </WebProjectProperties>

然后,您想要转到/ bin目录并删除以下文件(Project是您的项目名称):

Project.dll
Project.dll.CodeAnalysisLog.xml
Project.dll.config
Project.dll.CodeAnalysisLog
Project.pdb
Project.xml

重新构建,一切正常!