---
schema_version: "1"
id: 7beef560e64d0b7c094098cdf58b403725b24e6f37808f4f1855d4a24aa31d91
title: Microsoft .NET Connector
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/microsoft-dotnet-connector/3.0/index.md
canonical_url: https://docs.mulesoft.com/jp/microsoft-dotnet-connector/3.0/
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 3939601890757d7f9667ab72d4e4a515add765c4acd812ffcd897dafa1a01710
description: MuleSoft Documentation Site
release: "3.0"
latest: false
---
# Microsoft .NET Connector

Microsoft .NET Connector v3.0

Microsoft .NET 用 Anypoint Connector を使用すると、Mule アプリケーションでネイティブの .NET コードを実行できます。

サポートされているシナリオは、既存のバイナリアセンブリ (DLL) でコードを変更せずに実行することや、インテグレーションアプリケーションの機能を拡張する .NET コードを新たに開発することなどです。

このコネクタは、Java ネイティブインターフェース (JNI) を使用して .NET コードを実行します。JNI は Java 仮想マシン (JVM) と、ホストのオペレーティングシステムで実行されるネイティブアプリケーション間の高速プロセス間通信を可能にします。

このコネクタは Execute 操作という 1 つの操作をサポートします。ユーザーは実行するクラスやメソッドを選択し、そのメソッドに対応する引数を渡すことができます。

<table><tbody><tr><td class="icon"><i class="fa icon-note" title="Note"></i></td><td class="content">このコネクタには、Java 8 との互換性のみがあります。</td></tr></tbody></table>

リリースノート: [Microsoft .NET Connector リリースノート](https://docs.mulesoft.com/jp/release-notes/connector/microsoft-dotnet-connector-release-notes-mule-4)​  
Exchange: [Microsoft .NET Connector](https://www.mulesoft.com/exchange/com.mulesoft.connectors/mule-microsoft-dotnet-connector/)

## [](#始める前に)始める前に

この情報を使用するには、.NET、Mule Runtime Engine (Mule)、Anypoint Connector、Anypoint Studio、Mule の概念、Mule フローの要素、グローバル要素に精通している必要があります。

ソフトウェアの要件および互換性情報については、「コネクタリリースノート」を参照してください。

Maven でこのコネクタを使用するには、Anypoint Exchange の \[Dependency Snippets (連動関係スニペット)\] で pom.xml の連動関係情報を確認してください。

## [](#pom-ファイル情報)POM ファイル情報

```xml
<dependency>
  <groupId>com.mulesoft.connectors</groupId>
  <artifactId>mule-microsoft-dotnet-connector</artifactId>
  <version>x.x.x</version>
  <classifier>mule-plugin</classifier>
</dependency>
```

`x.x.x`​ を使用しているコネクタに対応するバージョンに置き換えます。

最新の ​`pom.xml`​ ファイル情報を取得するには、​ [Anypoint Exchange](https://www.mulesoft.com/exchange/)​ でコネクタにアクセスし、​**\[Dependency Snippets (連動関係スニペット)\]**​ をクリックします。

## [](#anypoint-studio-7-での接続)Anypoint Studio 7 での接続

このコネクタを Anypoint Studio で使用するには、まず Exchange からダウンロードして必要に応じて設定します。

## [](#studio-プロジェクトへのコネクタの追加)Studio プロジェクトへのコネクタの追加

Anypoint Studio には、Studio プロジェクトにコネクタを追加する 2 つの方法があります。Studio タスクバーの Exchange ボタンから追加するか、\[Mule Palette (Mule パレット)\] ビューから追加します。

### [](#exchange-を使用してコネクタを追加する)Exchange を使用してコネクタを追加する

1. Studio で Mule プロジェクトを作成します。
2. Studio タスクバーの左上にある Exchange アイコン ​**(X)**​ をクリックします。
3. Exchange で、​**\[Login (ログイン)\]**​ をクリックし、Anypoint Platform のユーザー名とパスワードを指定します。
4. Exchange で、「.net」を検索します。
5. コネクタを選択して ​**\[Add to project (プロジェクトに追加)\]**​ をクリックします。
6. 画面の指示に従ってコネクタをインストールします。

### [](#studio-でコネクタに追加する)Studio でコネクタに追加する

1. Studio で Mule プロジェクトを作成します。
2. \[Mule Palette (Mule パレット)\] ビューで、​**\[(X) Search in Exchange ((X) Exchange 内を検索)\]**​ をクリックします。
3. **\[Add Modules to Project (モジュールをプロジェクトに追加)\]**​ で、検索項目に「.net」と入力します。
4. **\[Available modules (使用可能なモジュール)\]**​ で、このコネクタの名前をクリックします。
5. **\[Add (追加)\]**​ をクリックします。
6. **\[Finish (完了)\]**​ をクリックします。

### [](#studio-で設定する)Studio で設定する

1. 選択したコネクタ操作を Studio キャンバスにドラッグします。
2. 一般設定で次の項目に入力します。
    
    ![Studio の \[General (一般)\] タブ](_images/microsoft-dotnet-connection.png)
    
    - Scope (スコープ): モジュールのスコープ。
        
        - Singleton (単一): .NET コンポーネントの同じインスタンスを複数のコールで共有します。このオプションは、さまざまなコールのクラスインスタンスメンバーに共有する状態を保存する場合に役立ちます。
        - Transient (一時的): 要求があった時点で .NET コンポーネントの新しいインスタンスを作成します。
    - Grant Full Trust to the assembly (アセンブリに完全信頼を付与): Mule Runtime の安定性に影響を及ぼす可能性のあるマルウェアコードの実行を阻止するために、制限された権限を使用して .NET コードをアプリケーションドメイン内で実行します。これらの制限には、限定的なファイルシステムへのアクセス、ネイティブコードの実行、ネットワークコール、レジストリアクセスなどが挙げられます。NET Connector はデフォルトで、完全信頼を使用するように設定されています。
        
        - Declared methods only (宣言されたメソッドのみ): デフォルト値は ​`true`​ です。
        - Include auto generated code (自動生成されたコードを含める): デフォルト値は ​`false`​ です。
3. \[Assembly (アセンブリ)\] セクションで選択した接続種別に応じて、項目を次のとおり指定します。
    
    - リソース接続種別の場合 - \[Path (パス)\] 項目に、リソースフォルダー (デフォルトのリソースフォルダーは src/main/resources) にある実行可能な .NET ライブラリへの相対パスを指定します。
        
        ![Studio のリソースアセンブリ](/mulesoft/current/ja-jp/microsoft-dotnet-connector/3.0/_images/microsoft-dotnet-resource-assembly.png)
    - 外部接続種別の場合 - \[Path (パス)\] 項目に、実行可能な .NET ライブラリへのフルパスを指定します。
        
        ![Studio の外部アセンブリ](/mulesoft/current/ja-jp/microsoft-dotnet-connector/3.0/_images/microsoft-dotnet-external-assembly.png)
    - GAC 接続種別の場合 - \[Assembly Type (アセンブリ種別)\] 項目に、完全修飾種別名 (例: `Namespace.ClassName`​) を指定します。この種の設定は、GAC (グローバルアセンブリキャッシュ) にインストールされているアセンブリに使用します。
        
        ![Studio のグローバルアセンブリ](/mulesoft/current/ja-jp/microsoft-dotnet-connector/3.0/_images/microsoft-dotnet-gac-assembly.png)
    - レガシー接続種別の場合 - \[Assembly Type (アセンブリ種別)\] 項目に、完全修飾種別名 (例: `Namespace.ClassName`​) を指定します。\[Assembly Path (アセンブリパス)\] には、.NET アセンブリのパス (例: `C:\Projects\..dll`​) を指定します。
        
        ![レガシーアセンブリ](/mulesoft/current/ja-jp/microsoft-dotnet-connector/3.0/_images/microsoft-dotnet-legacy-assembly.png)

## [](#ユースケース-studio)ユースケース: Studio

![Studio のフロー図](/mulesoft/current/ja-jp/microsoft-dotnet-connector/3.0/_images/microsoft-dotnet-use-case.png)

1. フローに HTTP リスナーを追加します。
2. 緑のプラス記号をクリックして設定します。
3. \[Host (ホスト)\] を「localhost」、\[Port (ポート)\] を「8081」に設定します。
4. \[OK\] をクリックします。
5. パレットの Microsoft .NET Connector から Execute 操作を追加します。
6. 緑のプラス記号をクリックして、接続を設定します。
7. 前述の「Studio での設定」セクションの説明に従って、項目を設定します。
8. 型とメソッドのパラメーターを選択して、引数を指定します。
9. Transform Message (メッセージの変換) DataWeave コンポーネントを追加して、次のとおり設定します。
    
    ```dataweave
    %dw 2.0
    output application/json
    ---
    payload
    ```
10. `localhost:8081`​ に対して curl を実行します。

## [](#ユースケース-xml)ユースケース: XML

```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>
```

## [](#関連情報)関連情報

[MuleSoft ヘルプセンター](https://help.mulesoft.com)