Biztalk Driven Addiction
posts - 14 , comments - 5 , trackbacks - 0

Wednesday, July 17, 2013

Could not load file or assembly 'Microsoft.Adapters.SAP.SAPGInvoker.dll'


Bad surprise today, When trying to create a receive location WCF-SAP in Biztalk administration console, I received this nice message :


Exception has been thrown by the target of an invocation. (mscorlib)


Exception has been thrown by the target of an invocation. (mscorlib)


Could not load file or assembly 'Microsoft.Adapters.SAP.SAPGInvoker.dll' or one of its dependencies. The specified module could not be found. (Microsoft.Adapters.SAP)

Program Location:

   at Microsoft.Adapters.SAP.SAPConnectionUri.ParseUri(Uri uri)
   at Microsoft.Adapters.SAP.SAPConnectionUri..ctor()

My Configuration was using the SAP RFC SDK 7.00 Unicode client package on a 64 bits server. After having triple checked the configuration files and installation I was starting to despair. The adapter has been running for months without issue on a dynamic send port.

I used ProcessMonitor and Process Explorer to monitor what was happening when i was opening the adapter configuration windows and after a while I realized the msvcr71.dll  was missing.

After deploying it in the SYSWOW64 folder it worked fine.

In the installation guide there is a reference to Visual C++ runtime dll for the SAP RFC SDK 7.10 but not for the earlier versions.

Let's hope I will save someone some headache on that one.

Edit 2015/01/21 Installing BizTalk 2013R2 then configuring BizTalk Adapter lead me to the same issues. Following the documentation, the only missing information is that you have to download 2 packages from SAP. Windows on x64 64bits (or the other 64bit depending on your HW) and Windows Server on IA32 32bits. The 32 bits version is only used by Visual Studio and the administration console (afaik).

Posted On Wednesday, July 17, 2013 4:55 PM | Comments (1) |

Tuesday, May 17, 2011

XML Stream Namespace

Sometimes I need to load a stream from a file in a Biztalk pipeline and I have to determine the Type of the message.

Here s how i do that :

// This is for sample only. Should refer to the message stream and rewind the stream

Stream fs = new FileStream(filepath, FileMode.Open); 

// End of stream initialisation.

XPathDocument sourceDoc = new XPathDocument(fs);

XPathNavigator navigator = sourceDoc.CreateNavigator();


string streamDocSchema = navigator.NamespaceURI + "#" + navigator.LocalName;

// Assigns the Namespace to the MessageType in context

Posted On Tuesday, May 17, 2011 5:16 PM | Comments (0) |

Thursday, September 23, 2010

Biztalk 2010 Release incoming next week...

Just read this post announcing that Biztalk server 2010 will be available from October 1st 2010.

Yeah that s my best news of the day.

I m worried, they dont say anything about the ESB toolkit 2.1 which was provided with the Beta version.

Enjoy !

Posted On Thursday, September 23, 2010 10:06 PM | Comments (0) |

Tuesday, July 20, 2010

Biztalk 2009 Mapping Issue

error btm1010: The "Scripting" functoid has 1 input parameter(s), but 0 parameter(s) are expected

Using Scripts from external assemblies.

Recreate the reference to the external assembly

Reset the Scripting functoid (Reset Button) and set the properties

Rebuild. should work.

Posted On Tuesday, July 20, 2010 10:10 AM | Comments (0) |

Monday, May 10, 2010

TDD and WCF behavior

Some weeks ago I wanted to develop a WCF behavior using TDD. I have lost some time trying to use mocks. After a while i decided to just use a host and a client. I don’t like this approach but so far I haven’t found a good and fast solution to use Unit Test for testing a WCF behavior.

To Implement my solution I had to :

  • Create a Dummy Service Definition;
  • Create the Dummy Service Implementation;
  • Create a host;
  • Create a client in my test;
  • Create and Add the behavior;

Dummy Service Definition

This is just a simple service, composed of an Interface and a simple implementation.

The structure is aimed to be easily customizable for my future needs.


Using Clauses :

   1: using System.Runtime.Serialization; 
   2: using System.ServiceModel; 
   3: using System.ServiceModel.Channels; 

The DataContract:

   1: [DataContract()] 
   2: public class MyMessage 
   3: { 
   4:     [DataMember()]
   5:     public string MessageString; 
   6: } 

The request MessageContract:

   1: [MessageContract()] 
   2: public class RequestMessage 
   3: { 
   4:     [MessageHeader(Name = "MyHeader", Namespace = "http://dummyservice/header", Relay = true)] 
   5:     public string myHeader; 
   7:     [MessageBodyMember()] 
   8:     public MyMessage myRequest; 
   9: } 

The response MessageContract:

   1: [MessageContract()] 
   2: public class ResponseMessage 
   3: { 
   4:     [MessageHeader(Name = "MyHeader", Namespace = "http://dummyservice/header", Relay = true)] 
   5:     public string myHeader; 
   7:     [MessageBodyMember()] 
   8:     public MyMessage myResponse; 
   9: } 

The ServiceContract:



Dummy Service Implementation

   1: public class DummyService:IDummyService 
   2: { 
   3:     #region IDummyService Members 
   4:     public ResponseMessage DoThis(RequestMessage request) 
   5:     { 
   6:         ResponseMessage response = new ResponseMessage(); 
   7:         response.myHeader = "Response"; 
   8:         response.myResponse = new MyMessage(); 
   9:         response.myResponse.MessageString = 
  10:                  string.Format("Header:<{0}> and Request was <{1}>", 
  11:                  request.myHeader, request.myRequest.MessageString); 
  12:         return response; 
  13:     } 
  14:     #endregion
  15:  }

Host Creation

The most simple host implementation using a Named Pipe binding. The GetBinding method will create a binding for the host and can be used to create the same binding for the client.

   1: public static class TestHost
   2: {
   4:     internal static string hostUri = "net.pipe://localhost/dummy";
   6:     // Create Host method.
   7:     internal static ServiceHost CreateHost()
   8:     {
   9:         ServiceHost host = new ServiceHost(typeof(DummyService));
  11:         // Creating Endpoint
  12:         Uri namedPipeAddress = new Uri(hostUri);
  13:         host.AddServiceEndpoint(typeof(IDummyService), GetBinding(), namedPipeAddress);
  15:         return host;
  16:     }
  18:     // Binding Creation method.
  19:     internal static Binding GetBinding()
  20:     {
  21:         NamedPipeTransportBindingElement namedPipeTransport = new NamedPipeTransportBindingElement();
  22:         TextMessageEncodingBindingElement textEncoding = new TextMessageEncodingBindingElement();
  24:         return new CustomBinding(textEncoding, namedPipeTransport);
  25:     }
  27:     // Close Method.
  28:     internal static void Close(ServiceHost host)
  29:     {
  30:         if (null != host)
  31:         {
  32:             host.Close();
  33:             host = null;
  34:         }
  35:     }
  36: }




Checking the service

A simple test tool check the plumbing.

   1: [TestMethod] 
   2: public void TestService() 
   3: { 
   4:     using (ServiceHost host = TestHost.CreateHost()) 
   5:     { 
   6:         host.Open(); 
   8:         using (ChannelFactory<IDummyService> channel = 
   9:                         new ChannelFactory<IDummyService>(TestHost.GetBinding() 
  10:                             , new EndpointAddress(TestHost.hostUri))) 
  11:         { 
  12:             IDummyService svc = channel.CreateChannel(); 
  13:             try 
  14:             { 
  15:                 RequestMessage request = new RequestMessage(); 
  16:                 request.myHeader = Guid.NewGuid().ToString(); 
  17:                 request.myRequest = new MyMessage(); 
  18:                 request.myRequest.MessageString = "I want some beer."; 
  20:                 ResponseMessage response = svc.DoThis(request); 
  21:             } 
  22:             catch (Exception ex) 
  23:             { 
  24:                 Assert.Fail(ex.Message); 
  25:             } 
  26:         } 
  27:         host.Close(); 
  28:     } 
  29: } 

Running the service should show that the client and the host are running fine.

So far so good.

Adding the Behavior

Add a reference to the Behavior project and add the using entry in the test class.

We just need to add the behavior to the service host :

   1: [TestMethod] 
   2: public void TestService() 
   3: { 
   4:     using (ServiceHost host = TestHost.CreateHost()) 
   5:     {
   6:         host.Description.Behaviors.Add(new MyBehavior()); 
   7:         host.Open();¨

 If you set a breakpoint in your behavior and run the test in debug mode, you will hit the breakpoint.

In this case I used a ServiceBehavior.

To add an Endpoint behavior you have to add it to the endpoints.

   1: host.Description.Endpoints[0].Behaviors.Add(new MyEndpointBehavior())

To add a contract or an operation behavior a custom attribute should work on the service contract definition. I haven’t tried that yet.


All the code provided in this blog and in the following files are for sample use.



I don’t like to instantiate a client and a service to test my behaviors. But so far I have' not found an easy way to do it.

Today I am passing a type of endpoint to the host creator and it creates the right binding type. This allows me to easily switch between bindings at will.

I have used the same approach to test Mex Endpoints, another post should come later for this.

Enjoy !


   1: [ServiceContract(Name="DummyService", Namespace="http://dummyservice",SessionMode=SessionMode.Allowed  )] 
   2: interface IDummyService 
   3: { 
   4:     [OperationContract(Action="Perform", IsOneWay=false, ProtectionLevel=System.Net.Security.ProtectionLevel.None )] 
   5:     ResponseMessage  DoThis(RequestMessage request); 
   6: }

Posted On Monday, May 10, 2010 1:02 AM | Comments (1) |

Wednesday, July 15, 2009

CSV to FlatFile Fast and Easy.

Using the String.Split() and the String.Format() methods I can format a flat file very fast.

Posted On Wednesday, July 15, 2009 4:02 PM | Comments (0) |

Friday, July 10, 2009

Unit Tests and Deployment Items


Sometimes one need an external file when running Unit Tests. The purpose can vary according to the situations:

  • Get information from a configuration file;
  • Use the file as a source of data;


Here are several possibilities to deploy those files when running Unit Tests :

  • Use The DeploymentItem Attribute on the TestClass. This is usefull for configuration files.

/// <summary>

/// Summary description for Test with files to deploy

/// </summary>

[TestClass, DeploymentItem("assembly.dll.config")]

public class AssemblyTest


public AssemblyTest()



  • Use the DeploymentItem Attribute on TestMethod. This is usefull for data files.

[TestMethod, DeploymentItem("mydata.csv")]

public void TestMyData()





  • Set the CopyToOutputDirectory Property to always on the desired file (config or data).




  • Open the LocalTestRun.testrunconfig file and Add Deployment Items (the Enable deployment check box must be checked ) :



In all cases the build engine will copy the files to the test run directory. For instance, from the Solution directory , TestResults\User_Computer 2009-07-13 16_11_00\Out .


Note: I wrote this using Visual Studio 2008 SP1.

Posted On Friday, July 10, 2009 2:29 PM | Comments (0) |

Tuesday, June 30, 2009

Unit Test and Impersonation

Usually as a developer I am logged with a user with more rights than a usual user. Even if I am not using the Admin account often I have to create one or more user with associated groups to simulate my target environment and log with those user and test my application. This is time consuming for me and i want to be sure I can retest those cases as often and as fast as I want. The idea may seem strange as those tests looks more like integration tests, but i don't want to deploy my application, t

Posted On Tuesday, June 30, 2009 11:25 AM | Comments (1) |

Thursday, January 1, 2009

Note on this blog

The articles contained in this blog are intended for my use only, and to keep a trace of my work for easy reuse. Yet I am sharing it with my thoughts. There might be better solutions I am not aware off and you are welcome to share your experiences.

The code provided is to be used with caution. You bear the risk of using it.

The pieces of code are provided “AS IS'”. The author disclaim all warranties, expressed or implied, including, without limitation, the warranties of merchantability and of fitness for any purpose. The authors assume no liability for direct, indirect, incidental, special, exemplary, or consequential damages, which may result from the use of this software or piece of code, even if advised of the possibility of such damage.

Posted On Thursday, January 1, 2009 10:59 AM | Comments (1) |

Monday, February 16, 2009

Windows Seven

After testing Windows seven for more than a month, here are my thoughts...

Posted On Monday, February 16, 2009 11:38 PM | Comments (1) |

Powered by: