SVCUTIL /CT:System.Collections.Generic.ObservableCollection not working

InspiredUser33157 216 Reputation points
2022-07-25T11:18:20.707+00:00

Attempting to include the "/ct:System.Collections.Generic.ObservableCollection`1" for my cmd line but it isn't acceting it.

The Error: No type could be loaded for the value System.Collections.Generic.ObservableCollection`1 passed to the /collectionType option.

I've added the NuGet package for the System.ObjectModel but when it installs, the .Net45 folder has a single zero byte file in it and it's not the "System.ObjectModel.dll". Where should I find this DLL?

Developer technologies | .NET | Other
0 comments No comments
{count} votes

Accepted answer
  1. Lan Huang-MSFT 30,191 Reputation points Microsoft External Staff
    2022-07-26T07:11:36.303+00:00

    Hi @InspiredUser33157 ,
    You can download System.ObjectModel.dll from the link below.
    https://www.nuget.org/packages/System.ObjectModel
    There is no DLL file, the downloaded package is in the packages.config folder.
    You can refer to the following command:
    svcutil http://MyWebweb.MyDomain.com/BrokerWcf.svc /r:"C:\Windows\Microsoft.NET\Framework64\v2.0.50727\System.dll" /ct:System.Collections.Generic.ObservableCollection`1
    I suggest you can take a look at the documentation:
    https://learn.microsoft.com/en-us/dotnet/framework/wcf/servicemodel-metadata-utility-tool-svcutil-exe
    Best regards,
    Lan Huang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

3 additional answers

Sort by: Most helpful
  1. InspiredUser33157 216 Reputation points
    2022-07-26T10:55:25.627+00:00

    I've installed the NuGet package and changed the \r: path to your suggestion but still getting the same error:

    "Error: No type could be loaded for the value System.Collections.ObjectModel.ObservableCollection'1 passed to the /collectionType option. Ensure that the assembly this type belongs to is specified via the /reference option."

    My complete cmd line is :

    svcutil http://MyWeb.csitgroup.com/BrokerWcf.svc /Language=c# /t:Code /out:"C:\Users\csalerno\Projects\MyWeb 3.x\MyWeb v3.x\MyWeb.Setup\Service References\BrokerWcfSvc\Reference.cs" /config:"C:\Users\csalerno\Projects\MyWeb 3.x\MyWeb v3.x\MyWeb.Setup\Service References\BrokerWcfSvc\ServiceProxy.config" /async /namespace:"*,MyWeb.Setup.BrokerWcfSvc" /tcv:Version35 /ct:System.Collections.ObjectModel.ObservableCollection /r:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.dll"

    Should the \tcv: be set to Version4.5.2?

    0 comments No comments

  2. InspiredUser33157 216 Reputation points
    2022-07-26T13:09:10.197+00:00

    I continued to play with the cmd line params and finally worked the error out with the following cmd line, but having an issue with using the correct Class.

    svcutil http://localhost:61394/BrokerWcf.svc /Language=c# /t:Code /out:"C:\Users\csalerno\Projects\MyWeb 3.x\MyWeb v3.x\MyWeb.Setup\Service References\BrokerWcfSvc\Reference.cs" /config:"C:\Users\csalerno\Projects\MyWeb 3.x\MyWeb v3.x\MyWeb.Setup\Service References\BrokerWcfSvc\ServiceProxy.config" /async /namespace:"*,MyWeb.Setup.BrokerWcfSvc" /tcv:Version35 /ct:System.Collections.ObjectModel.ObservableCollection`1 /r:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.ObjectModel.dll"

    But getting this one last error:
    Severity Code Description Project File Line Suppression State
    Error CS0029 Cannot implicitly convert type 'System.Collections.ObjectModel.ObservableCollection<MyWeb.Setup.BrokerWcfSvc.Broker>' to 'System.Collections.ObjectModel.ObservableCollection<DTP.Data.Broker>' MyWeb.Setup C:\Users\csalerno\Projects\MyWeb 3.x\MyWeb v3.x\MyWeb.Setup\ViewModels\BrokerViewModel.cs 277 Active

    The "DTP.Data.Broker" is in another DLL and I found no examples of adding multiple DLL references to the /r: parameter. Is this what is missing? Why is it trying to use "MyWeb.Setup.BrokerWcfSvc.Broker" instead of the correct "DTP.Data.Broker"?

    0 comments No comments

  3. InspiredUser33157 216 Reputation points
    2022-07-26T13:19:59.373+00:00

    Looks like you can simple add another "/r:" switch to include another DLL Reference.

    svcutil http://localhost:61394/BrokerWcf.svc /Language=c# /t:Code /out:"C:\Users\csalerno\Projects\MyWeb 3.x\MyWeb v3.x\MyWeb.Setup\Service References\BrokerWcfSvc\Reference.cs" /config:"C:\Users\csalerno\Projects\MyWeb 3.x\MyWeb v3.x\MyWeb.Setup\Service References\BrokerWcfSvc\ServiceProxy.config" /async /namespace:"*,MyWeb.Setup.BrokerWcfSvc" /tcv:Version35 /ct:System.Collections.ObjectModel.ObservableCollection`1 /r:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.ObjectModel.dll" /r:c:\MyDLL.dll

    No it builds successfully.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.