Contact Free trial Login

Microsoft .NET Connector


The .NET connector lets you execute native .NET code in a Mule Runtime application.

Supported scenarios include: executing code in an existing binary assembly (DLL) without modification, or new development of .NET code that extends the capability of your integration application.

This connector executes .NET code using the Java Native Interface (JNI), which provides fast interprocess communication between the Java Virtual Machine (JVM) and a native application running in a host operating system.

The connector supports one operation, the Execute operation, which allows users to select a class and a method to be executed and to pass the corresponding arguments for that method.


This document assumes that you are familiar with Mule, Anypoint Connectors, Anypoint Studio, Mule concepts, elements in a Mule flow, and Global Elements.

For hardware and software requirements and compatibility information, see the Connector Release Notes.

To use this connector with Maven, view the pom.xml dependency information in the Dependency Snippets in Anypoint Exchange.

Note: This connector is not supported for use with Anypoint Design Center.

What’s New in this Connector

First Mule 4 release.

Connect in Anypoint Studio 7

You can use this connector in Anypoint Studio by first downloading it from Exchange and configuring it as needed.

Install Connector in Studio

  1. In Anypoint Studio, click the Exchange icon in the Studio taskbar.

  2. Click Login in Anypoint Exchange.

  3. Search for this connector and click Install.

  4. Follow the prompts to install this connector.

Configure in Studio

  1. Drag and drop the connector to the Studio Canvas.

  2. For general settings complete these fields:

    Studio General tab
    • Scope: The scope of the module:

      • Singleton: Shares the same instance of the .NET component across multiple calls. This is useful for storing a shared state in class instance members across different calls.

      • Transient: Creates a new instance of the .NET component per request.

    • Grant Full Trust to the assembly: .NET code can be executed in an application domain with restricted privileges to avoid the execution of malware code that can affect the stability of the Mule Runtime. These restrictions include limited access to the file system, native code execution, network calls, registry access, and more. By default the .NET connector is set to use full trust.

      • Declared methods only: true is the default value.

      • Include auto generated code: false is the default value.

  3. Given the selected connection type in the Assembly section, specify the fields as follows:

    • For the Resource connection type - The Path field contains the relative path to an executable .net library in the resources folder (the default resources folder is src/main/resources).

      Studio Resource Assembly
    • For the External connection type - The Path field contains the full path to an executable .net library.

      Studio External Assembly
    • For the GAC connection type - The Assembly Type field contains the fully qualified type name (for example, Namespace.ClassName). This type of configuration is used with an assembly installed in the GAC (Global Assembly Cache).

      Studio Global Assembly
    • For the Legacy connection type - The Assembly Type field contains the fully qualified type name (for example, Namespace.ClassName). The Assembly Path should contain Provide the path of the .NET assembly (for example, C:\Projects\..dll).

      Legacy Assembly

Use Case: Studio

Studio Flow Diagram
  1. Add an HTTP Listener to the flow.

  2. Click the green plus sign to configure it.

  3. Set Host to localhost and Port to 8081.

  4. Click OK.

  5. Add the Execute operation from Microsoft .NET connector from the pallet.

  6. Configure a connection by clicking the green plus sign.

  7. Set the fields as described in the previous "Configure in Studio" section.

  8. Select the Type and the Method parameter and provide the arguments.

  9. Add a Transform Message DataWeave component and set it as follows:

    %dw 2.0
    output application/json
  10. Perform a curl to localhost:8081.

Use Case XML

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:ee=""
	<http:listener-config name="HTTP_Listener_config"
	doc:name="HTTP Listener config"
		<http:listener-connection host="localhost" port="8081" />
	<dotnet:dot-net-config name="Microsoft_DotNet" doc:name="Microsoft DotNet">
		<dotnet:resource-connection scope="Singleton" path="DemoDotNet.dll" />
	<flow name="sum-of-digits">
		<http:listener doc:name="Listener"
		<ee:transform doc:name="Transform Message">
			<ee:message >
				<ee:set-payload ><![CDATA[%dw 2.0
output application/json
	number: payload.num
		<dotnet:execute doc:name="Execute" config-ref="Microsoft_DotNet"
		type="DemoDotNet.NumberLibrary, DemoDotNet, Version=,
		Culture=neutral, PublicKeyToken=PUBLIC_KEY_TOKEN"
		method="DemoDotNet.NumberLibrary, DemoDotNet, Version=,
		PublicKeyToken=PUBLIC_KEY_TOKEN | SumOfDigits(System.Int32 number) -&gt; System.Int32"/>
		<ee:transform doc:name="Transform Message">
			<ee:message >
				<ee:set-payload ><![CDATA[%dw 2.0
output application/json


We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used and to tailor advertising. You can read more and make your cookie choices here. By continuing to use this site you are giving us your consent to do this.