TypeLoadException: Could not load type ‘type name’ from assembly ‘assembly name, Version=1.0.0.0, Culture=neutral, PublicKeyToken=…’

Posted: February 22, 2012  |  Categories: Administration BizTalk

Recently I was testing a new BizTalk solution version with a couple of new features when I came across with the following error:

Uncaught exception (see the ‘inner exception’ below) has suspended an instance of service ‘MyService(4dfd3eeb-5cb2-9ca5-2e15-59dd321e72ed)’.
The service instance will remain suspended until administratively resumed or terminated.
If resumed the instance will continue from its last persisted state and may re-throw the same unexpected exception.
InstanceId: b8b6c570-516c-4e40-a07a-96632f7e8506
Shape name:
ShapeId:
Exception thrown from: segment -1, progress -1
Inner exception: Could not load type ‘type name’ from assembly ‘assembly name, Version=1.0.0.0, Culture=neutral, PublicKeyToken=…’.
Exception type: TypeLoadException
Source: …
Target Site: Microsoft.XLANGs.Core.StopConditions segment1(Microsoft.XLANGs.Core.StopConditions)

This error occurs after invoking the service or after dropping a file to the receive location.

Cause

  • You didn’t install the assembly specified in the error.
  • Your DLL depends on other DLL’s to get its job done and if you didn’t copy or install those too, you’d indeed get this error message.
  • Or you have installed an older version of the assembly.

This error occurs often when we use C# HelperClass to support the orchestrations, but can occur in other situations.

Solution

Make sure that you have the last version of the assembly installed.

  • Rebuild the solution.
  • Deploy the correct solution.
#1 Azure Monitoring Platform
Author: Sandro Pereira

Sandro Pereira lives in Portugal and works as a consultant at DevScope. In the past years, he has been working on implementing Integration scenarios both on-premises and cloud for various clients, each with different scenarios from a technical point of view, size, and criticality, using Microsoft Azure, Microsoft BizTalk Server and different technologies like AS2, EDI, RosettaNet, SAP, TIBCO etc. He is a regular blogger, international speaker, and technical reviewer of several BizTalk books all focused on Integration. He is also the author of the book “BizTalk Mapping Patterns & Best Practices”. He has been awarded MVP since 2011 for his contributions to the integration community.

4 thoughts on “TypeLoadException: Could not load type ‘type name’ from assembly ‘assembly name, Version=1.0.0.0, Culture=neutral, PublicKeyToken=…’”

  1. Hi Sandro,

    thank you for your tireless work, It was of great help for me on several occasions. 🙂

    Allow me an addition to your post from my everyday-work:
    When you do not work with different versions of a DLL, occasionally it happens that a DLL is not overwritten correctly in GAC during deployment.
    To counter this: Uninstall the DLL from GAC, make sure that it is not present any more and install the new version (maybe just using gacutil, because it has been registered correctly in MgmtDB during deployment).
    It might help to verify the current DLL in GAC using Reflector or a similar tool. E.g. if you want to check a map in Reflector, look for “XMLContent” where you can find the XML representation of the map.

    Best regards
    mipsen

  2. This also occur to me when testing a Worker under System.Reflection;

    Below Code:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Reflection;

    namespace MarshalObjectFramework
    {
    public class Worker : MarshalByRefObject
    {
    public void PrintDomain()
    {
    Console.WriteLine(“Object is executing in AppDomain \”{0}\””,
    AppDomain.CurrentDomain.FriendlyName);
    }
    }
    class Program
    {
    static void Main(string[] args)
    {
    // Create an ordinary instance in the current AppDomain
    Worker localWorker = new Worker();
    localWorker.PrintDomain();

    // Create a new application domain, create an instance
    // of Worker in the application domain, and execute code
    // there.
    AppDomain ad = AppDomain.CreateDomain(“New domain”);
    Worker remoteWorker = (Worker)ad.CreateInstanceAndUnwrap(
    typeof(Worker).Assembly.FullName,
    “Worker”);
    remoteWorker.PrintDomain();
    }
    }
    }

    Both on VS 2017/ 2019 same error

Leave a Reply

Your email address will not be published. Required fields are marked *

turbo360

Back to Top