Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Help converting code

2 views
Skip to first unread message

Mark Goldin

unread,
Nov 6, 2009, 9:27:20 AM11/6/09
to
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

Mark Rae [MVP]

unread,
Nov 6, 2009, 10:43:40 AM11/6/09
to
"Mark Goldin" <mgo...@UFANDD.LOCAL> wrote in message
news:eZRTO2uX...@TK2MSFTNGP06.phx.gbl...

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

<snip>

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

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...


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Mark Goldin

unread,
Nov 6, 2009, 10:49:41 AM11/6/09
to
A, I see. It's because C# cannot produce a DLL?

"Mark Rae [MVP]" <ma...@markNOSPAMrae.net> wrote in message
news:OTTrlfvX...@TK2MSFTNGP06.phx.gbl...

Mark Rae [MVP]

unread,
Nov 6, 2009, 11:43:16 AM11/6/09
to
"Mark Goldin" <mgo...@UFANDD.LOCAL> wrote in message
news:OcrMQkv...@TK2MSFTNGP04.phx.gbl...

[please don't top-post]

>>> I need some help converting the code to produce a dll or something else
>>> in order to run this application from non .net environments.
>>
>> 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...
>

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

You can create .NET assemblies as DLLs. You can make them COM-visible. You
can use a tool called regasm to make them work like Windows DLLs. However,
all of these still require the CLR.

If you want to create a "true" Windows DLL which doesn't require the .NET
Framework, you'll need to use something other than C# or any other managed
programming language.

Scott M.

unread,
Nov 6, 2009, 11:59:43 AM11/6/09
to
> 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


Mark Goldin

unread,
Nov 6, 2009, 12:29:22 PM11/6/09
to
The not.net environment is VB6.
I simply want to create an object, call its method and get results back.

"Scott M." <s-...@nospam.nospam> wrote in message
news:eyMQJJwX...@TK2MSFTNGP05.phx.gbl...

Scott M.

unread,
Nov 6, 2009, 1:21:44 PM11/6/09
to

"Mark Goldin" <mgo...@UFANDD.LOCAL> wrote in message
news:Oiev8bwX...@TK2MSFTNGP06.phx.gbl...

> 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


Mark Goldin

unread,
Nov 6, 2009, 5:10:27 PM11/6/09
to
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.

"Scott M." <s-...@nospam.nospam> wrote in message

news:ex6892wX...@TK2MSFTNGP04.phx.gbl...

Family Tree Mike

unread,
Nov 6, 2009, 5:16:47 PM11/6/09
to

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

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

--
Mike

Mark Goldin

unread,
Nov 6, 2009, 5:19:34 PM11/6/09
to
I could but I decided to use native to SSRS web services environment - .Net.
Then use it in VB as a wrapper.

"Family Tree Mike" <FamilyT...@ThisOldHouse.com> wrote in message
news:OXURT7yX...@TK2MSFTNGP04.phx.gbl...

Jeff Johnson

unread,
Nov 6, 2009, 5:22:12 PM11/6/09
to
"Family Tree Mike" <FamilyT...@ThisOldHouse.com> wrote in message
news:OXURT7yX...@TK2MSFTNGP04.phx.gbl...

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


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

With the SOAP Toolkit, probably.


Scott M.

unread,
Nov 6, 2009, 5:36:30 PM11/6/09
to

"Mark Goldin" <mgo...@UFANDD.LOCAL> wrote in message
news:O0plA5yX...@TK2MSFTNGP04.phx.gbl...

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


Mark Goldin

unread,
Nov 6, 2009, 5:42:15 PM11/6/09
to
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." <s-...@nospam.nospam> wrote in message

news:eWxjVFzX...@TK2MSFTNGP05.phx.gbl...

Scott M.

unread,
Nov 6, 2009, 5:52:53 PM11/6/09
to

"Mark Goldin" <mgo...@UFANDD.LOCAL> wrote in message
news:ubMNyKzX...@TK2MSFTNGP06.phx.gbl...

>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


Arne Vajhøj

unread,
Nov 6, 2009, 9:44:31 PM11/6/09
to

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

0 new messages