ReferencedTypeDoesNotMatch thrown on correct DataContract
- Dominant language
- C#
- Stars
- 1.8k
- Forks
- 576
- Avg merge
- 6d 9h
- Merged PRs (30d)
- 2
Description
**Describe the bug**
I have a WCF service that uses two DLLs with base types. Once we reference that base types, the data contract will throw the ReferencedTypeDoesNotMatch.
There must be a difference to older versions, where the Reference.cs has been written / even the referenced types are not used and therefore generated as duplicates.
The WSDL File is generated right before creating the service - so I assume that this is correct.
The strange thing this is, that this is only one service that is not working - other WSDL files in our project can be used without any hassle.
**To Reproduce**
Steps to reproduce the behavior:
1. I created a .NET Solution that produces the error with the current svc-util v8.0.0
2. You have to run the build.ps1 file
3. It crahes on CodeExporter.GetReferencedType
When serializing the object it throws a null reference exception
```
---> System.NullReferenceException: Object reference not set to an instance of an object.
at System.Runtime.Serialization.DataMember.CriticalHelper.get_MemberType() in C:\Github\wcf\src\dotnet-svcutil\lib\src\FrameworkFork\System.Runtime.Serialization\System\Runtime\Serialization\DataMember.cs:line 264
at System.Runtime.Serialization.DataMember.get_MemberType() in C:\Github\wcf\src\dotnet-svcutil\lib\src\FrameworkFork\System.Runtime.Serialization\System\Runtime\Serialization\DataMember.cs:line 142
```
**Fix**
The fix is to change to comparison in CodeExporter.GetReferencedType (Line 563)
from:` if (referencedContract.Equals(dataContract))`
to: `if (referencedContract.StableName.Equals(dataContract.StableName))`
**Expected behavior**
That the Reference.cs will be created with respect to the referenced data types.
**Screenshots**
If applicable, add screenshots to help explain your problem.

[Error_WSDL_DataContract.zip](https://github.com/user-attachments/files/19906870/Error_WSDL_DataContract.zip)
Contributor guide
Assessment
This issue has not been assessed yet.