programing

이 WCF 오류의 의미 : "사용자 지정 도구 경고 : wsdl : portType을 가져올 수 없습니다."

nasanasas 2020. 9. 23. 07:43
반응형

이 WCF 오류의 의미 : "사용자 지정 도구 경고 : wsdl : portType을 가져올 수 없습니다."


내 솔루션에서 WCF 서비스 라이브러리 프로젝트를 만들고 이에 대한 서비스 참조가 있습니다. 클래스 라이브러리의 서비스를 사용하므로 클래스 라이브러리 외에도 WPF 응용 프로그램 프로젝트의 참조가 있습니다. 서비스는 간단하게 설정되며 비동기 서비스 기능을 얻기 위해서만 변경됩니다.

내 서비스 참조를 업데이트하고 싶을 때까지 모든 것이 잘 작동했습니다. 실패했기 때문에 결국 롤백하고 다시 시도했지만 그때도 실패했습니다! 따라서 서비스 참조 업데이트는 변경하지 않고 실패합니다. 왜?!

내가 얻는 오류는 다음과 같습니다.

Custom tool error: Failed to generate code for the service reference 
'MyServiceReference'.  Please check other error and warning messages for details.   

경고는 추가 정보를 제공합니다.

Custom tool warning: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: 
System.ServiceModel.Description.DataContractSerializerMessageContractImporter
Error: List of referenced types contains more than one type with data contract name 'Patient' in  
namespace 'http://schemas.datacontract.org/2004/07/MyApp.Model'. Need to exclude all but one of the 
following types. Only matching types can be valid references: 
"MyApp.Dashboard.MyServiceReference.Patient, Medski.Dashboard, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" (matching)
"MyApp.Model.Patient, MyApp.Model, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" (matching)
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:portType[@name='ISomeService']

다음과 같은 두 가지 유사한 경고도 있습니다.

Custom tool warning: Cannot import wsdl:binding
Detail: There was an error importing a wsdl:portType that the wsdl:binding is dependent on.
XPath to wsdl:portType: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:portType[@name='ISomeService']
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:binding[@name='WSHttpBinding_ISomeService']  

그리고 동일 :

Custom tool warning: Cannot import wsdl:port .. 

이 모든 것이 혼란 스럽습니다. 서비스 참조를 통해 얻은 것 외에는 클라이언트 측 대시 보드에 Patient 클래스가 없습니다. 그래서 그것은 무엇을 의미합니까? 그리고 왜 갑자기 표시됩니까? 기억하십시오 : 나는 아무것도 변경하지 않았습니다!

이제 이것에 대한 해결책이 여기 에서 발견 되었지만 이것이 의미하는 바에 대한 설명은 없습니다. 그래서; 서비스에 대한 "서비스 참조 구성"에서 "참조 된 어셈블리의 유형 재사용"확인란을 선택 취소합니다. 지금 재건하면 문제없이 잘 작동합니다. 그러나 내가 정말로 무엇을 바꿨습니까? 이것이 내 응용 프로그램에 영향을 미칠까요? 그리고 언제 이것을 선택 취소해야합니까? DataContract를 설정 한 유형을 재사용하고 싶지만 더 이상 사용하지 않습니다. 이 항목을 선택하지 않아도 계속 액세스 할 수 있습니까?


서비스 참조를 추가 할 때 서비스에서 사용하는 유형을 처리 할 수있는 두 가지 방법이 있습니다.

  • 유형은 dll에 저장되며 해당 dll은 클라이언트와 서버 응용 프로그램 모두에서 참조됩니다.
  • 클라이언트가 참조하는 dll에 유형이 없습니다. 이 경우 서비스 참조를 생성하는 도구는 references.cs 파일에 유형을 생성합니다.

잘못 될 수있는 것들이 많이 있습니다. 도구가 충돌하면 때때로 서비스 참조를 삭제하고 다시 시작하는 것이 더 빠르다는 것을 발견했습니다.

서비스 참조 사용을 중지했습니다. 클라이언트와 서비스를 제어하는 ​​프로젝트의 경우이 스크린 캐스트에 설명 된 방법을 사용합니다 .


내 대답은 http://www.lukepuplett.com/2010/07/note-to-self-don-let-wcf-svcutil-reuse.html 에서 찾았습니다.

간단히 말해서 , 고급 메뉴 에서 참조 어셈블리 에서 유형 재사용을 선택 취소했습니다 .


이것이 중요한지 모르겠지만 MVC가 아니라 Web Forms를 사용하고 있습니다.


오늘도이 문제가있었습니다. 실수를 찾는 데 하루 종일 걸렸습니다. 도움이되기를 바랍니다.

가져올 수 없었던 내 클래스에 cutom enum 유형 속성이 있습니다. 이 속성은 DataMember로 표시되고 Enum은 DataContract로도 표시됩니다. 지금까지는 괜찮습니다. 모든 열거 형 멤버를 EnumMember로 표시하는 것을 잊었습니다.

그래서 나는 변했다

[DataContract]
public enum SortMethodType
{
    Default = 0,
    Popularity = 1,
    ReleaseDate = 2,
    PublishedDate = 3,
    TranslatedTitle = 4,
    OriginalTitle = 5,
    UserRating = 6,
    Duration = 7
}

이에:

[DataContract]
public enum SortMethodType
{
    [EnumMember]
    Default = 0,
    [EnumMember]
    Popularity = 1,
    [EnumMember]
    ReleaseDate = 2,
    [EnumMember]
    PublishedDate = 3,
    [EnumMember]
    TranslatedTitle = 4,
    [EnumMember]
    OriginalTitle = 5,
    [EnumMember]
    UserRating = 6,
    [EnumMember]
    Duration = 7
}

그리고 마침내 작동했습니다!


참조를 추가하면서 고급 속성으로 이동하여 체크리스트에서 "System.Window.Browser"를 제거하면 문제가 해결됩니다.


that might sound weird, but I got it fixed by deleting the references, then closing Visual Studio, and reopening it again, and finally adding the references again.

I think the custom tool thing needed to be restarted or something.


I constantly run across this error while it works on another developers machine. Even though I'm a full admin everywhere in my virtual machine, I tried closing Visual Studio, and re-opening with 'Run As Administrator' and it magically worked.

Good luck.


I got the warning after upgrading my solution from Visual Studio (VS) 2010 to 2013 and changing each project's .NET Framework from 4 to 4.5.1. I closed VS and re-opened and the warnings went away.


One downside of turning off 'reuse types in referenced assemblies' is that it can cause issues with ambiguous references. This is due to the service reference creating those objects again in the reference .cs file, and your code implementing the service may be referencing them from the original namespace.

When this scenario occurs I find it useful to check the 'reuse types in specified referenced assemblies' which allows me to choose the ones with ambiguous references only, which resolves the issue quickly that way.

Hope it helps someone else.


My interfaces of the WCF service are in an assembly, the implementation is in an another and the service reference is in yet another assembly, separate from the clients of the service reference. I got the error message right after I applied the DataContract to an enum. After I applied EnumMember to the fields of the enum, the issue resolved.


If in doubt that your service doesn't have any problems (such as problems with enums, or non-serializable classes as mentioned by others) then try to create a new project with a new reference.

I am using Silverlight 5 and I had tried to delete and recreate the reference several times. The reference.cs file just came up completely empty each time and it had been literally years since I'd created it so trying to figure out what had changed in the service was out of the question.

I noticed that the error contained references to 2.0.5.0. Now I don't even know if this is actually relevant to the Silverlight version, but it made me think of just creating a brand new project and then suddenly everything worked.

Warning 2 Custom tool warning: Cannot import wsdl:portType Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter Error: Could not load file or assembly 'System.Xml, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The system cannot find the file specified. XPath to Error Source: //wsdl:definitions[@targetNamespace='']/wsdl:port Type[@name='IShoppingCart']


I was looking over my project and I was having this same issue. It turned out to be different versions of the same DLL on the WCF vs. Web Site. Web site had a newer version of the DLL and the service was referencing an older version of the DLL. Once they were all in sync all worked well.


I experienced the same error. I struggled for almost a day trying to find out what was going wrong. The clue for me were the warnings that VS was throwing. It was trying to do some kind of mapping to Yahoo.Yui.Compressor.dll, a library I had added and removed (because I decided not to use it) a couple of days before. It was shocking because the library wasn't there, but somehow it was trying to reference it.

Finally, I restore this dll from the Trash, and then I could update my service reference successfully.


For anyone here in the future, I had the same error but caused by version issues, in two different ways.

I have two WCF services and two client applications that talk via the service references. I updated a nuget package on both sides and tried to update the service reference and got this error.

Deleting didn't help. Unchecking "reuse assemblies" is not desired as I need to reuse them - that's the whole point.

In the end, there were two separate issues:

1) The first issue, I believe, was a visual studio caching issue. I meticulously went over all of the references and found no issues but it still reported being unable to find the previous version of the file. I uninstalled all of the nuget packages, restarted visual studio, and reinstalled them. Updating the service reference worked.

2) The second issue was caused by a dependency issue. I updated the nuget package on both sides and everything appeared correct, but an unmarked dependency was out of sync. Example:

Package Foo v1 references Bar v1. It is possible to update Foo and Bar to v2 independently without updating the reference. If you install both Foo and Bar v2 the service reference tool will scan Foo v2, see the reference to Bar v1, and fail because it can't find the older version. This is only reported correctly if you update the version numbers of your dll for every package. Visual Studio and MSBuild will have no problem building the application but the service reference will have a terrible time trying to resolve everything.

I hope this helps someone.

참고URL : https://stackoverflow.com/questions/1872865/what-does-this-wcf-error-mean-custom-tool-warning-cannot-import-wsdlporttype

반응형