2

I'm currently getting an error trying to resolve my IDataAccess class.

The value of the property 'type' cannot be parsed. The error is: Could not load file or assembly 'TestProject' or one of its dependencies. The system cannot find the file specified. (C:\Source\TestIoC\src\TestIoC\TestProject\bin\Debug\TestProject.vshost.exe.config line 14)

This is inside a WPF Application project.

What is the correct syntax to refer to the Assembly you are currently in? is there a way to do this? I know in a larger solution I would be pulling Types from seperate assemblies so this might not be an issue. But what is the right way to do this for a small self-contained test project. Note: I'm only interested in doing the XML config at this time, not the C# (in code) config.

UPDATE: see all comments

My XML config:

<configuration>
  <configSections>
    <section name="unity" type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection, Microsoft.Practices.Unity.Configuration" />
  </configSections>
  <unity>
    <typeAliases>
      <!-- Lifetime manager types -->
      <typeAlias alias="singleton"  type="Microsoft.Practices.Unity.ContainerControlledLifetimeManager, Microsoft.Practices.Unity" />
      <typeAlias alias="external" type="Microsoft.Practices.Unity.ExternallyControlledLifetimeManager, Microsoft.Practices.Unity" />
      <typeAlias alias="IDataAccess" type="TestProject.IDataAccess, TestProject" />
      <typeAlias alias="DataAccess" type="TestProject.DataAccess, TestProject" />
    </typeAliases>
    <containers>
      <container name="Services">
        <types>
          <type type="IDataAccess" mapTo="DataAccess" />
        </types>
      </container>
    </containers>
  </unity>
</configuration>

3 Answers 3

3

In unity 5.7

The section line should be like this

<section name="unity" type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection,Unity.Configuration" />

Sign up to request clarification or add additional context in comments.

Comments

0

This looks fine. Are you sure your assembly name is correct? Check the project preferences to make sure the name of your assembly is correct:

  1. Right click your project and click Properties
  2. Click on the Application tab on the left
  3. Look at the value of the "Assembly Name" field.

Sometimes if you've renamed your project, this field will still be the old value.

It's possible that this is not the issue at all, but it is the simplest thing to check. If you find that this is not the issue, reply to this and I'll post any other ideas I have.

Also, you might consider posting your sample as a .zip file so we can take a look at it.

5 Comments

One problem is the app project is TestProject, but when Visual Studio is running it in debug it runs it as TestProject.vhost.exe. I added the vhost into name in the XML file and this did not help.
I can't upload the sample because in order to not be paralyzed by this issue, I split the code into two assemblies so I could just keep moving forward. One class library project and one WPF project.
The name of the DLL and the name of the assembly have nothing to do with each other. This is why I asked you to interrogate the name of the assembly.
Oh. The assembly name was the same though.
Turn on Fusion Logging, then. You've likely got something that you are referencing from that DLL that isn't available. The application to do that is FusLogVw.exe
0

I just had the same issue. this works for me : Turn "Copy local" to true in the properties of Microsoft.Practices.Unity. You should also add a reference to Microsoft.Practices.ObjectBuilder2 (Microsoft.Practices.Unity depends of it)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.