ReportingService2010 could not be found

痴心易碎 提交于 2019-12-18 03:41:58

问题


I have:

private readonly ReportingService2010 _rs = new ReportingService2010();

Error:

The type or namespace name 'ReportingService2010' could not be found (are you missing a using directive or an assembly reference?)

I setup a reference to the SSRS service. The reference does not give me access to ReportingService2010 as I expect. The closest thing is:

MySsrsServiceNamespace.ReportingService2010SoapClient

How am I supposed to use the ReportingService2010 class? MSDN lists this class vaguely.

Please note I tried using ReportingService2010SoapClient. This class does not match the documentation for ReportingService2010. For example, ListChildren() only accepts 4 parameters and the Url property does not exist.


回答1:


Either create a proxy class and include it in your application or add a web reference to ReportingService. The tutorial is available there:

http://technet.microsoft.com/en-us/library/ms155134.aspx

Note that if you are going for proxy class and you are using more than one endpoint (ReportExecution, ReportingService) you should generate proxy classes on different namespaces, otherwise you will get clashes.

Did you do it by web reference? If so, try using WSDL at the command line. Command line syntax:

wsdl /language:CS /n:"Microsoft.SqlServer.ReportingServices2010" http://serverName/reportserver/ReportService2010.asmx?wsdl



回答2:


Just ran into the exact same issue. ReportingService2010SoapClient class was available, but the ReportingService2010 class was not. Was driving me nuts. I had added it as a "Service References", but you have to add it as a "Web References", like so:

  1. Delete your old Service Reference

  2. Right click on References. The "Add Service Reference" dialog comes up.

  3. Do not enter the WSDL URL now, instead: Click on the "Advanced" button at the bottom left.

  4. The "Service Reference Settings" dialog comes up.

  5. At the bottom left, click the "Add Web Reference" button.

  6. Now enter the URL for the WSDL. (for me that was servername/ReportServer/ReportService2010.asmx)

  7. Click the small arrow on the right, it will take its sweet time to load.

  8. Name the web reference, I used "ReportingService2010WebReference", but ReportingService2010" probably works just as well.

  9. Click "Add Reference"

  10. In your code, update your using statements to "using .ReportingService2010WebReference (or whatever name you picked)

Code:

private MySol.ReportService2010WebReference.ReportingService2010 rsClient;

rsClient = new ReportingService2010();
rsClient.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;

CatalogItem[] items = null;

items = rsClient.ListChildren("/", false);

foreach (var item in items)
{
    tr.ErrorMessage += (item.Path + " " + item.CreatedBy);
}

Worked on the first try. Web.config file wasn't touched.




回答3:


Do not add a Webreference

Follow the following steps and it would work just fine.

1) Make sure you have .netframework >= 4.6.1

2) Run command prompt as administrator

3) cd C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools

4) Generate class: wsdl /proxyusername:Username /proxypassword:Password -out:Reportingservice2010.cs http://Servername/Reportserver/ReportService2010.asmx?wsdl

Additional) Run wsdl /? for help Files will output in: C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools

5) Add the .cs file to your project




回答4:


Change this;

private readonly ReportingService2010 _rs = new ReportingService2010()

to

private readonly ReportingService2010SoapClient _rs = new ReportingService2010SoapClient()

You are attempting to create an instance to a class that does not exists and adding the reference creates a corresponding *Client class for you to instantiate.



来源:https://stackoverflow.com/questions/18964295/reportingservice2010-could-not-be-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!