Visual Studio calling inline assembly manifest ignored when debugging

My .NET client application has a dependency on another assembly. This dependency is declared in the file app.manifest

:

app.manifest

<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

  <assemblyIdentity version="1.0.0.0" name="Contoso.Frobber.Admin"/>

  <!-- We have a dependancy on Grobber -->
  <dependency>
    <dependentAssembly>
      <assemblyIdentity type="win32" name="Contoso.Grobber" version="1.0.0.0" processorArchitecture="x86" />
    </dependentAssembly>
  </dependency>

  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
    <security>
      <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
        <!-- UAC Manifest Options
        <requestedExecutionLevel level="asInvoker" uiAccess="false" />
      </requestedPrivileges>
    </security>
  </trustInfo>

  <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
    <application>
      <!-- Windows 7-->
      <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
    </application>
  </compatibility>

</asmv1:assembly>

      

And then the project is configured to use our file app.manifest

. You specify the use of a user app.manifest

in ProjectAppendixResources :

enter image description here

And it all works

I have to make sure to place another assembly in the same folder ^ 1. For example:

Contoso.Grobber.manifest

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">

  <assemblyIdentity type="win32" name="Contoso.Grobber" version="1.0.0.0" processorArchitecture="x86" />

  <file name = "Grobberify.dll">
    <comClass
          progid="Contoso.Grobberify"
          clsid="{EB4B9718-0625-4505-BBF2-42CF7E94643E}"
          description="Grobber system frobs"
          threadingModel = "Apartment" />
  </file>
</assembly>

      

So I have in my folder:

  • SampleApplication.exe
  • Contoso.Grobber.Manifest
  • Grobberify.dll

And everything works. My application starts up and everything behaves correctly.

I can prove that my inline manifest is being executed because if I change my inline manifest to require something called Contoso.Grobber asdfasfaraasdf :

  <!-- We have a dependancy on Grobber -->
  <dependency>
    <dependentAssembly>
      <assemblyIdentity type="win32" name="asdfasfaraasdf" version="1.0.0.0" processorArchitecture="x86" />
    </dependentAssembly>
  </dependency>

      

If I run my application now, the Fusion loader realizes that there is no assembly called asdfasfaraasdf and throws an error on loading:

enter image description here

The application failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the sxstrace.exe command line tool for more details.

And if I will return your dependent assembly to the correct asdfasfaraasdfContso.Grobber , then everything will work.

Except when debugging

For no particular reason, if I am inside a debugger then the merge loader does not see my assembly manifest and its dependent assemblies.

I can prove this by declaring in my assembly manifest that I am dependent on an assembly that does not exist (eg name = "asdfasdfasf")

![enter image description here][3]

      

The app shouldn't start - but it does ! No matter what I do:

  • use the fake assembly name
  • remove the manifest of my child assembly
  • remove .dll

    my dependent assembly

The application wo n't launch. This means that any version of my executable running in Visual Studio does not have any built-in app.manifest

.

It's a problem because it's broken

You might think that having the application work well - I wouldn't want it to fail. This is incorrect for two reasons:

  • i want it not to start if the required assembly is missing
  • the dependent assembly contains the necessary information about the merge

The assembly I am downloading is a COM dll. My .manifest

file contains much needed COM clsid

and filename information. When Visual Studio doesn't honor my application manifest, the Fusion loader won't see my unregistered COM objects:

<comClass
      progid="Contoso.Grobberify"
      clsid="{EB4B9718-0625-4505-BBF2-42CF7E94643E}"
      description="Grobber system frobs"
      threadingModel = "Apartment" />
  </file>

      

Without this assembly comClass information, my .NET application cannot create a COM object while debugging:

[ComImport]
[Guid("EB4B9718-0625-4505-BBF2-42CF7E94643E")]
public class Grabasstic
{
}

IGrobberAss ga = (IGrobberAss)new Grabasstic();

      

enter image description here

This only happens when debugging

This Visual Studio Community 2013 crash on Windows 7 64-bit with a 32-bit app with a logged in user that doesn't have a customized wallpaper only happens when debugging the app. If I run SampleApplication.exe directly, the inline assembly flag has .

Perhaps it is because Visual Studio is not debugging

SampleApplication.exe

Visual Studio is actually debugging an application named:

SampleApplication.vshost.exe

Or not. What do I know?

How do I make it work?

I know there is no solution. The number of people on the planet who have experience with no COM registration is limited:

It's safe to say that no one actually read the entire "Research Effort" block above. I'm also curious to know which users caught the Easter egg there, as well as who would be complaining about too much research.

In fact, I know there is no solution. And while I can document the fact that this is a problem, I have no idea that anyone can solve it. Which makes this whole 45 minute question a way for me to talk about intractable problems.

Reading bonuses

+3


source to share


2 answers


The solution was to disable the process of hosting Studio the Visual by ProjectProject Properties :. p>

enter image description here



Based on the MSDN documentation of the hosting process , it has no real value to developers and can be safely disabled.

+4


source


Delete the * .vshost.exe file. Windows caches manifest information to a binary file (EXE, DLL), so it will use the first configuration used with the * .vshost.exe file.

This does not happen if you are running the application or are not using the Visual Studio host, because your binaries change when you recompile. However, the * .vshost.exe file is not modified or affected at all.



You have to manually delete it and let Visual Studio recreate / copy it again. Or better yet, try without a Visual Studio host.

Here is the correct link: Windows Vista Sxs Activation Contextual Cache . I'm guessing it still works this way in 8.1 and the upcoming 10.

+1


source







All Articles