|
1 | 1 | --- |
2 | 2 | title: "MSB3247 diagnostic code" |
3 | 3 | description: "Found conflicts between different versions of the same dependent assembly. In Visual Studio, double-click this warning (or select it and press Enter) to fix the conflicts; otherwise, add the following binding redirects to the 'runtime' node in the application configuration file:" |
4 | | -ms.date: 12/06/2024 |
| 4 | +ms.date: 2/6/2025 |
5 | 5 | ms.topic: "error-reference" |
6 | 6 | f1_keywords: |
7 | 7 | - MSB3247 |
@@ -31,9 +31,38 @@ MSB3247: Found conflicts between different versions of the same dependent assemb |
31 | 31 | ``` |
32 | 32 |
|
33 | 33 | <!-- :::editable-content name="postOutputDescription"::: --> |
34 | | -<!-- |
35 | | -{StrBegin="MSB3247: "} |
36 | | ---> |
| 34 | + |
| 35 | +## Remarks |
| 36 | + |
| 37 | +This error occurs when building .NET Framework projects. It is generated by the `ResolveAssemblyReference` task. There are two modes that `ResolveAssemblyReference` can run in, either it can be configured to generate binding redirects, or not. If not set, this error occurs when a conflict occurs between two different assembly versions of dependent assembly. |
| 38 | + |
| 39 | +## Resolution |
| 40 | + |
| 41 | +Consider the following solutions: |
| 42 | + |
| 43 | +### Solution 1: Configure MSBuild to automatically generate binding redirects |
| 44 | + |
| 45 | +Check the property `AutoGenerateBindingRedirects`, which configures `ResolveAssemblyReference` to generate the redirects automatically. You can set this property in Visual Studio. Open **Project Properties** (<kbd>Alt</kbd>+<kbd>Enter</kbd>), open the **Application** tab, and select the checkbox **Auto-generate binding redirects**. |
| 46 | + |
| 47 | +Or, to generate binding redirects automatically by editing the project file, add the following property in one of the `PropertyGroup` elements in the project file: |
| 48 | + |
| 49 | +`<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>` |
| 50 | + |
| 51 | +See [Enable and disable automatic binding redirection](/dotnet/framework/configure-apps/how-to-enable-and-disable-automatic-binding-redirection). |
| 52 | + |
| 53 | +### Solution 2: Add binding redirects to the `app.config` or `web.config` file |
| 54 | + |
| 55 | +You can add the binding redirects manually in the configuration file (such as`app.config` or `web.config`) as suggested in the warning output text. This option is appropriate if you choose not to allow MSBuild to generate the binding redirects automatically, perhaps because you want them explicitly listed in the configuration files to reduce ambiguity. |
| 56 | + |
| 57 | +If you choose not to generate binding redirects automatically, update the `app.config` file (or `web.config`) to add the binding redirects explicitly. The warning message provides the XML for the binding redirects that you can copy and paste into the `runtime` element of the `app.config` file. |
| 58 | + |
| 59 | +Alternately, MSBuild writes binding redirects to an output file if the property `GenerateBindingRedirectsOutputType` is true. It's automatically set to true in the .NET Framework build for executable output files, but you can also set it to true manually for `.dll` output. When MSBuild generates the binding redirects, it adds them to a `.config` file in the output directory, which also contains any binding redirects found in the `app.config` or `web.config` file. You can copy the binding redirects from there and paste the XML into an `app.config` file under the `runtime` element if you want them to be explicitly visible there, or if you don't want MSBuild to generate them automatically. |
| 60 | + |
| 61 | +See [Troubleshooting assembly references](../troubleshoot-assembly-references.md). |
| 62 | + |
| 63 | +## Related content |
| 64 | + |
| 65 | +- [Redirecting assembly versions](/dotnet/framework/configure-apps/redirect-assembly-versions) |
37 | 66 | <!-- :::editable-content-end::: --> |
38 | 67 | <!-- :::ErrorDefinitionDescription-end::: --> |
39 | 68 |
|
|
0 commit comments