Microsoft .NET Connector | MuleSoft Documentation
# Microsoft .NET Connector
Microsoft .NET Connector v3.0
Anypoint Connector for Microsoft .NET enables you to execute native .NET code in a Mule 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 execute, and to pass the corresponding arguments for that method.
This connector is compatible only with Java 8.   
---  
Release Notes: Microsoft .NET Connector Release Notes Exchange: Microsoft .NET Connector
## Before You Begin
To use this information, you should be familiar with .NET, Mule runtime engine (Mule), Anypoint Connectors, Anypoint Studio, Mule concepts, elements in a Mule flow, and Global Elements.
For 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.
## POM File Information
```
<dependency>
 <groupId>com.mulesoft.connectors</groupId>
 <artifactId>mule-microsoft-dotnet-connector</artifactId>
 <version>x.x.x</version>
 <classifier>mule-plugin</classifier>
</dependency>
```

Replace `x.x.x` with the version that corresponds to the connector you are using.
To obtain the most up-to-date `pom.xml` file information, access the connector in Anypoint Exchange and click **Dependency Snippets**.
## Connect in Anypoint Studio 7
You can use this connector in Anypoint Studio by first downloading it from Exchange and configuring it as needed.
## Add the Connector to a Studio Project
Anypoint Studio provides two ways to add the connector to your Studio project: from the Exchange button in the Studio taskbar or from the Mule Palette view.
### Add the Connector Using Exchange
  1. In Studio, create a Mule project.
  2. Click the Exchange icon **(X)** in the upper-left of the Studio task bar.
  3. In Exchange, click **Login** and supply your Anypoint Platform username and password.
  4. In Exchange, search for ".net".
  5. Select the connector and click **Add to project**.
  6. Follow the prompts to install the connector.


### Add the Connector in Studio
  1. In Studio, create a Mule project.
  2. In the Mule Palette view, click **(X) Search in Exchange**.
  3. In **Add Modules to Project** , type ".net" in the search field.
  4. Click this connector’s name in **Available modules**.
  5. Click **Add**.
  6. Click **Finish**.


### Configure in Studio
  1. Drag the connector operation of your choice to the Studio canvas.
  2. For general settings complete these fields:
     * 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).
     * For the External connection type - The Path field contains the full path to an executable .net library.
     * 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).
     * 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`).


## Use Case: Studio
  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
---
payload
```

  10. Perform a curl to `localhost:8081`.


## Use Case XML
```
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
xmlns:dotnet="http://www.mulesoft.org/schema/mule/dotnet"
xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core
http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http
http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/dotnet
http://www.mulesoft.org/schema/mule/dotnet/current/mule-dotnet.xsd
http://www.mulesoft.org/schema/mule/ee/core
http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd">
	<http:listener-config name="HTTP_Listener_config"
	doc:name="HTTP Listener config"
		<http:listener-connection host="localhost" port="8081" />
	</http:listener-config>
	<dotnet:dot-net-config name="Microsoft_DotNet" doc:name="Microsoft DotNet">
		<dotnet:resource-connection scope="Singleton" path="DemoDotNet.dll" />
	</dotnet:dot-net-config>
	<flow name="sum-of-digits">
		<http:listener doc:name="Listener"
		config-ref="HTTP_Listener_config"
		path="/sumOfDigits"/>
		<ee:transform doc:name="Transform Message">
			<ee:message >
				<ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
{
	number: payload.num
}]]></ee:set-payload>
			</ee:message>
		</ee:transform>
		<dotnet:execute doc:name="Execute" config-ref="Microsoft_DotNet"
		type="DemoDotNet.NumberLibrary, DemoDotNet, Version=1.0.0.0,
		Culture=neutral, PublicKeyToken=PUBLIC_KEY_TOKEN"
		method="DemoDotNet.NumberLibrary, DemoDotNet, Version=1.0.0.0,
		Culture=neutral,
		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
---
payload]]></ee:set-payload>
			</ee:message>
		</ee:transform>
	</flow>
</mule>
```

## See Also
MuleSoft Help Center