Help converting code

M

Mark Goldin

I have the following code for a console application that I got from a MS web
site:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Services.Protocols;
using WebServiceAccessReports.ufddbreportservices;

namespace WebServiceAccessReports
{
class Program
{
static void Main(string[] args)
{
ReportingService2005 rs = new ReportingService2005();
rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
string report = "/154";
bool forRendering = false;
string historyID = null;
ParameterValue[] values = null;
DataSourceCredentials[] credentials = null;
ReportParameter[] parameters = null;

try
{
parameters = rs.GetReportParameters(report, historyID,
forRendering, values, credentials);

if (parameters != null)
{
foreach (ReportParameter rp in parameters)
{
Console.WriteLine("Name: {0}", rp.Name);
}
}
}

catch (SoapException e)
{
Console.WriteLine(e.Detail.InnerXml.ToString());
}

}
}
}
I need some help converting the code to produce a dll or something else in
order to run this application from non .net environments.

TIA
 
M

Mark Goldin

A, I see. It's because C# cannot produce a DLL?

Mark Rae said:
1) Decide which language you want to use to write your DLL. C++ is still
widely used for such programming tasks, but by no means your only choice.

2) Once you've made your decision, post your question in a newsgroup
dedicated to that language - you'll (almost) certainly get a far better
and quicker response...
 
S

Scott M.

I need some help converting the code to produce a dll or something else in
order to run this application from non .net environments.

TIA

What "non .net" environments do you mean?

Do you mean from Windows directly?

Do you mean from a non-Windows box on a private network?

Do you mean from a non-Windows box across the web?

You can write code in .NET that produces a .dll, and if you configure that
..dll properly, you can create a proxy that can be called from COM objects,
thus making your .NET .dll available to COM.

If you want your .NET .dll available over the web, you should expose the
class as a Web Service, which would allow Windoss and non-Windows platforms
alike the ability to consume your class(es).

But, if you want to strictly write .NET code that is immediately available
to non-.NET environments, that is not possible.

-Scott
 
M

Mark Goldin

The not.net environment is VB6.
I simply want to create an object, call its method and get results back.
 
S

Scott M.

Mark Goldin said:
The not.net environment is VB6.
I simply want to create an object, call its method and get results back.

Then, you'll need to code the .NET code just as it is, but mark the assembly
as availble for COM InterOp in the project's properties.

Then, you can use the .NET "regasm.exe" tool, to generate a COM Callable
Wrapper (CCW) that your VB 6 application can make a reference to and use as
if the .NET assembly was a COM object the whole time.

There isn't anything you need to do to your C# code.

http://msdn.microsoft.com/en-us/library/w29wacsy(VS.80).aspx

-Scott
 
M

Mark Goldin

This is what I have so far:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Services.Protocols;
using WebServiceAccessReports.ufddbreportservices;

namespace WebServiceAccessReports
{
public class Program
{
static void Main(string[] args)
{
}
public string getParameters(string reportFile)
{
ReportingService2005 rs = new ReportingService2005();
rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
string report = reportFile;
bool forRendering = false;
string historyID = null;
string returnStr = "";
ParameterValue[] values = null;
DataSourceCredentials[] credentials = null;
ReportParameter[] parameters = null;

try
{
parameters = rs.GetReportParameters(report, historyID,
forRendering, values, credentials);
if (parameters != null)
{
foreach (ReportParameter rp in parameters)
{
returnStr = returnStr + " " + rp.Name;
//Console.WriteLine("Name: {0}", rp.Name);
}
}
}

catch (SoapException e)
{
Console.WriteLine(e.Detail.InnerXml.ToString());
}
return returnStr;

}
}
}


I built it as a class library I ran regasm utility with no problem.
My question is: do I instantiate WebServiceAccessReports.Program or what?

Thanks for all the help.
 
F

Family Tree Mike

Mark said:
The not.net environment is VB6.
I simply want to create an object, call its method and get results back.

I know I'm going to regret this, but...

Can't you call the web service from VB 6?
 
M

Mark Goldin

I could but I decided to use native to SSRS web services environment - .Net.
Then use it in VB as a wrapper.
 
S

Scott M.

Mark Goldin said:
This is what I have so far:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Services.Protocols;
using WebServiceAccessReports.ufddbreportservices;

namespace WebServiceAccessReports
{
public class Program
{
static void Main(string[] args)
{
}
public string getParameters(string reportFile)
{
ReportingService2005 rs = new ReportingService2005();
rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
string report = reportFile;
bool forRendering = false;
string historyID = null;
string returnStr = "";
ParameterValue[] values = null;
DataSourceCredentials[] credentials = null;
ReportParameter[] parameters = null;

try
{
parameters = rs.GetReportParameters(report, historyID,
forRendering, values, credentials);
if (parameters != null)
{
foreach (ReportParameter rp in parameters)
{
returnStr = returnStr + " " + rp.Name;
//Console.WriteLine("Name: {0}", rp.Name);
}
}
}

catch (SoapException e)
{
Console.WriteLine(e.Detail.InnerXml.ToString());
}
return returnStr;

}
}
}


I built it as a class library I ran regasm utility with no problem.
My question is: do I instantiate WebServiceAccessReports.Program or what?

Thanks for all the help.

It looks like you have a Console application here, even though you built it
as a class libary. You should build this as a class library project from
the start. But yes, after you get your COM proxy, you just make an instance
of the class and use it as usual.

-Scott
 
M

Mark Goldin

I surely will.
But I tried run it and I got something working, but all the way.
When I run getParameters ...
I am getting:
OLE IDispatch exception code 0 from mscorlib: Request for the permission of
type
'System.Security.Permissions.EnvironmentPermission, mscorlib, Version ....
Culture ... PublicKeyToken ......
failed ....
What do I need to provide?

Thanks agian.

Scott M. said:
Mark Goldin said:
This is what I have so far:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Services.Protocols;
using WebServiceAccessReports.ufddbreportservices;

namespace WebServiceAccessReports
{
public class Program
{
static void Main(string[] args)
{
}
public string getParameters(string reportFile)
{
ReportingService2005 rs = new ReportingService2005();
rs.Credentials =
System.Net.CredentialCache.DefaultCredentials;
string report = reportFile;
bool forRendering = false;
string historyID = null;
string returnStr = "";
ParameterValue[] values = null;
DataSourceCredentials[] credentials = null;
ReportParameter[] parameters = null;

try
{
parameters = rs.GetReportParameters(report, historyID,
forRendering, values, credentials);
if (parameters != null)
{
foreach (ReportParameter rp in parameters)
{
returnStr = returnStr + " " + rp.Name;
//Console.WriteLine("Name: {0}", rp.Name);
}
}
}

catch (SoapException e)
{
Console.WriteLine(e.Detail.InnerXml.ToString());
}
return returnStr;

}
}
}


I built it as a class library I ran regasm utility with no problem.
My question is: do I instantiate WebServiceAccessReports.Program or what?

Thanks for all the help.

It looks like you have a Console application here, even though you built
it as a class libary. You should build this as a class library project
from the start. But yes, after you get your COM proxy, you just make an
instance of the class and use it as usual.

-Scott
 
S

Scott M.

Mark Goldin said:
I surely will.
But I tried run it and I got something working, but all the way.
When I run getParameters ...
I am getting:
OLE IDispatch exception code 0 from mscorlib: Request for the permission
of type
'System.Security.Permissions.EnvironmentPermission, mscorlib, Version ....
Culture ... PublicKeyToken ......
failed ....
What do I need to provide?

Thanks agian.

Not exactly sure since I'm not familiar with your entire setup, but I'd
Google the exact error you got for some ideas on what is the problem and
potential cures.

-Scott
 
A

Arne Vajhøj

Jeff said:
With the SOAP Toolkit, probably.

It should work. It is COM based. VB6 use COM.

But it is an IDE from 1998 using a kit from 2003.

Not particular attractive.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top