Adding a web reference as reference in a c# script not working

374 views
Skip to first unread message

poddarsumit

unread,
Jun 12, 2011, 4:29:23 PM6/12/11
to CS-Script
Hi

In a script using the Visual Studio IDE created a webreference say
(webreference 1).
However to access the webreference Visual Studio resolves it as
ConsoleApplication1.webreference1.
This works fine from within the IDE.

However trying to run it from the command line it fail saying
c:\Users\sumit.poddar.EUTANDBERG\Documents\CS-Scripts\new script
(1).cs(9,9): er
ror CS0246: The type or namespace name 'ConsoleApplication1' could not
be found

Could not find any info about using web references using CS-Script so
would be good to know how it can be done.

Cheers
Sumit

Oleg Shilo

unread,
Jun 12, 2011, 7:53:53 PM6/12/11
to cs-s...@googlegroups.com
Hello Sumit,
 
After VS created WebService proxy you just need to copy it and then reference from the script with //css_ref... After all it is nothing else but a simple managed assembly.
 
You can also create the proxy assembly directly from the script code direct from the script. Though it would require you understanding command-line interface of wsdl.exe. Thus if you are not comfortable with this using VS would be a preferred choice for you. Otherwise have a look here: http://www.csscript.net/help/ws.html.
 
  
Regards,
Oleg Shilo
--------------------------------------------------------------------------------------------
Internet: http://www.csscript.net
E-Mail: csscript...@gmail.com
You can register for e-mail notification on CS-Script updates: Add to mailing list

sumit poddar

unread,
Jun 12, 2011, 8:00:56 PM6/12/11
to cs-s...@googlegroups.com
Hi Oleg

I would like to do it the VS way rather than the command line way.

A quick question though.

When you say to copy the WebService proxy from where can I copy it.

The steps taken to create the web reference are

1) Reference -> Service Reference -> Web Reference.

I am not sure whether the webservice proxy class would have been created. It does not appear to have created it in the script folder.
When I click the web reference it does not seem to tell me the folder location.

Cheers
Sumit

Oleg Shilo

unread,
Jun 12, 2011, 8:16:58 PM6/12/11
to cs-s...@googlegroups.com
The proxy assembly is generated by VS (through execution of wsdl.exe) in one of the project temporary directories. Typical sample:
 
C:\...\Documents\Visual Studio 2010\Projects\WcfService2\ConsoleApplication1\obj\x86\Debug\TempPE\Service References.ServiceReference1.Reference.cs.dll
 
Cheers,

Oleg Shilo
--------------------------------------------------------------------------------------------
Internet: http://www.csscript.net
E-Mail: csscript...@gmail.com



sumit poddar

unread,
Jun 12, 2011, 8:49:50 PM6/12/11
to cs-s...@googlegroups.com
Hi Oleg

Thanks. That worked.

Regards
Sumit

sumit poddar

unread,
Jun 12, 2011, 9:11:08 PM6/12/11
to cs-s...@googlegroups.com
Is it just enough to copy the cs.dll file.

I find that till the solution is open in Visual studio it works via VS and command line.
However as soon as I close Visual studio it fails.

I have copied the .cs.dll file to a separate directory and accessing the file using //css_ref

I get an error

c:\Users\sumit.poddar.EUTANDBERG\Documents\CS-Scripts\new script (1).cs(12,9): error CS0246: The type or namespace name 'Test1' could not be found (are you missing a using directive or an assembly reference?)

Do I need to copy all the folders or just this 1 file should do.

Regards
Sumit

On Mon, Jun 13, 2011 at 12:16 PM, Oleg Shilo <oleg....@gmail.com> wrote:

Oleg Shilo

unread,
Jun 12, 2011, 9:34:27 PM6/12/11
to cs-s...@googlegroups.com
No Sumit,
 
You need just copy either *.cs.dll and inject //css_ref or you can copy the proxy code (yes VS also generates it) and use //css_include instead.
 
I included the sample for you. Please review and analyses the all file structure and you will see what VS is generating. A have also isolated two proxy alternatives and the script file in the Asms folder.
 
Cheers,
Oleg Shilo
--------------------------------------------------------------------------------------------
Internet: http://www.csscript.net
E-Mail: csscript...@gmail.com



ConsoleApplication1.7z

sumit poddar

unread,
Jun 12, 2011, 10:04:14 PM6/12/11
to cs-s...@googlegroups.com
Thanks Oleg..

Using your examples really helped.

For some reason referencing //css_ref .dll does not seem to work.  Says

Could not load file or assembly 'Web References.Test.Reference.cs, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

I am wondering whether that might be because .dll is making it look for the file in a particular location and having copied the dll file to a different location its unable to locate the file it needs.

However //css_inc to the reference.cs file works.

Also not sure whether the fact that I am using a webreference and you are using a service reference is making a difference.

However //css_inc works perfectly when I am referencing the references.cs file.

Cheers
Sumit

Oleg Shilo

unread,
Jun 14, 2011, 12:23:53 AM6/14/11
to CS-Script
Hi Sumit,

Conceptually referencing .dll and including .cs is not different thus
both should work. In fact the .dll is nothing else but a compilation
result of the reference.cs.

If you have concerns about location of the assembly specify it with
the full absolute path in your "//css_ref". Another troubleshooting
trick is to use /verbose switch.

You can also right-click the script and open it in VS. This way you
will see what dependency files the script engine is trying to
reference/include.

Cheers,
Oleg
> > ---------------------------------------------------------------------------­-----------------
> > Internet:http://www.csscript.net
> > E-Mail: csscript.supp...@gmail.com
>
> > On Mon, Jun 13, 2011 at 11:11 AM, sumit poddar <poddarsu...@gmail.com>wrote:
>
> >> Is it just enough to copy the cs.dll file.
>
> >> I find that till the solution is open in Visual studio it works via VS and
> >> command line.
> >> However as soon as I close Visual studio it fails.
>
> >> I have copied the .cs.dll file to a separate directory and accessing the
> >> file using //css_ref
>
> >> I get an error
>
> >> c:\Users\sumit.poddar.EUTANDBERG\Documents\CS-Scripts\new script
> >> (1).cs(12,9): error CS0246: The type or namespace name 'Test1' could not be
> >> found (are you missing a using directive or an assembly reference?)
>
> >> Do I need to copy all the folders or just this 1 file should do.
>
> >> Regards
> >> Sumit
>
> >> On Mon, Jun 13, 2011 at 12:16 PM, Oleg Shilo <oleg.sh...@gmail.com>wrote:
>
> >>> The proxy assembly is generated by VS (through execution of wsdl.exe) in
> >>> one of the project temporary directories. Typical sample:
>
> >>> C:\...\Documents\Visual Studio
> >>> 2010\Projects\WcfService2\ConsoleApplication1\obj\x86\Debug\TempPE\Service
> >>> References.ServiceReference1.Reference.cs.dll
>
> >>> Cheers,
>
> >>> Oleg Shilo
>
> >>> ---------------------------------------------------------------------------­-----------------
> >>> Internet:http://www.csscript.net
> >>> E-Mail: csscript.supp...@gmail.com
>
> >>> On Mon, Jun 13, 2011 at 10:00 AM, sumit poddar <poddarsu...@gmail.com>wrote:
>
> >>>> Hi Oleg
>
> >>>> I would like to do it the VS way rather than the command line way.
>
> >>>> A quick question though.
>
> >>>> When you say to copy the WebService proxy from where can I copy it.
>
> >>>> The steps taken to create the web reference are
>
> >>>> 1) Reference -> Service Reference -> Web Reference.
>
> >>>> I am not sure whether the webservice proxy class would have been
> >>>> created. It does not appear to have created it in the script folder.
> >>>> When I click the web reference it does not seem to tell me the folder
> >>>> location.
>
> >>>> Cheers
> >>>> Sumit
>
> >>>> On Mon, Jun 13, 2011 at 11:53 AM, Oleg Shilo <oleg.sh...@gmail.com>wrote:
>
> >>>>> Hello Sumit,
>
> >>>>> After VS created WebService proxy you just need to copy it and then
> >>>>> reference from the script with //css_ref... After all it is nothing else but
> >>>>> a simple managed assembly.
>
> >>>>> You can also create the proxy assembly directly from the script
> >>>>> code direct from the script. Though it would require you understanding
> >>>>> command-line interface of wsdl.exe. Thus if you are not comfortable with
> >>>>> this using VS would be a preferred choice for you. Otherwise have a look
> >>>>> here:http://www.csscript.net/help/ws.html.
>
> >>>>> Regards,
> >>>>> Oleg Shilo
>
> >>>>> ---------------------------------------------------------------------------­-----------------
> >>>>> Internet:http://www.csscript.net
> >>>>> E-Mail: csscript.supp...@gmail.com
> >>>>> You can register for e-mail notification on CS-Script updates: Add to
> >>>>> mailing list <csscript.supp...@gmail.com?subject=MailingListAdd>
>
> >>>>> On Mon, Jun 13, 2011 at 6:29 AM, poddarsumit <poddarsu...@gmail.com>wrote:
>
> >>>>>> Hi
>
> >>>>>> In a script using the Visual Studio IDE created a webreference say
> >>>>>> (webreference 1).
> >>>>>> However to access the webreference Visual Studio resolves it as
> >>>>>> ConsoleApplication1.webreference1.
> >>>>>> This works fine from within the IDE.
>
> >>>>>> However trying to run it from the command line it fail saying
> >>>>>> c:\Users\sumit.poddar.EUTANDBERG\Documents\CS-Scripts\new script
> >>>>>> (1).cs(9,9): er
> >>>>>> ror CS0246: The type or namespace name 'ConsoleApplication1' could not
> >>>>>> be found
>
> >>>>>> Could not find any info about using web references using CS-Script so
> >>>>>> would be good to know how it can be done.
>
> >>>>>> Cheers
> >>>>>> Sumit- Hide quoted text -
>
> - Show quoted text -
Reply all
Reply to author
Forward
0 new messages