Web service reference problems from SmartClient, someone from MS please review

J

JDeats

I have a WinForms application that I'm trying to deploy as a
"SmartClient" (where .exe downloads and auto launches from IE using
..NET IEExec process).
Part of my criteria for the app is to be able to get to pass
parameters into it. I found a way to do this though the
Environment.GetCommandLineArgs(); method call and passing in
attributes just as I would with an ASP or ASP.NET page (e.g.
http://myserver/myapp.exe?name=jdeats&age=27)I couldn't find this
documented anywhere, but it does work. The call to
Environment.GetCommandLineArgs() returns a string array with two
elements. The first element points to the location of IExec.exe, the
second element has the full URL with my parameters and a session
hashcode appended to the end, it looks something like this

http://myserver/myapp.exe?name=jdeats&age=27#1FB539C2A00E4E1C8...

This seemed to be consistent, so I wrote a method to parse out the
name/value pairs from the parameter list and proceeded to call
System.Web.HttpUtility.UrlDecode() on each of them.

This approach worked well until I added a Web Reference to my project,
anytime I attempt to call a web service from my app it fails if
parameters (e.g. ?name=jdeats&age=27) have been passed in. The error
message is as follows:

"Error loading XML file
http://myserver/myapp.exe?name=jdeatsage=27.config. There is an
invalid character in the given encoding"

Note that: no where in the code am I attempting to load a .config file
of any sort, an app.config has never been added to the project. The
Web Reference is set to "Static", yet some method call (I presume an
internal Microsoft method) has converted:
"http://myserver/myapp.exe?name=jdeats&age=27 into
"http://myserver/myapp.exe?name=jdeatsage=27.config".

With the more params I attempt to add, it's always the same. '&'
characters are stripped away and a ".config" is concatenated on to the
end. As a result of this the web service call can not be made. I'd
like to know if this is a bug or is it a by-design behavior. If it's
by-design what are my work around options.
 
C

Chris Botha

I saw that Dino Chiesa from Microsoft made his daily rounds on the newsgroup
without stopping at your message, so I don't know if you will get a response
from MS.
I don't think there is a simple solution. The article below may help.
http://msdn.microsoft.com/library/en-us/dnforms/html/winforms05152003.asp?frame=true

I guess if I had to do it, I would have gone one of two ways.
(1) Embed a User Control on the ASPX page, rather than a full fledged app.
The ASPX page can stick the values into the control and the control can pop
up the main form, etc.
http://samples.gotdotnet.com/quickstart/winforms/doc/WinFormsIeSourcing.aspx

(2) Let the ASPX store the parameters, along with the IP address of the
request in SQL Server, and when the Smart Client hits the server for the 1st
time, get the parms from SQL Server for this IP address, etc.

Let us know what you did in the end, it will be interesting.
 
J

JDeats

Chris,

Thanks for those hyperlinks, Chris Sells article on "No Touch
Deployment" was exactly what I was looking for, following his advice I
implemented a custom HttpHandler for .exe files and inside that code I
perform the needed conversion:

http://myserver/myapp.exe?name=johnage=25.config
becomes:
http://myserver/myapp.exe.config

Although that neither file actually exist, the conversion makes it
possiblE for web service calls to be made.

I contacted Microsoft developer support and they told me this was a
security feature and recommended a workaround that involved embededing
a control and performing a manual download of all the files for my app
(into a temp folder) then performing System.Diagonistics.Process
spawn... I kindly told them this would circumvent the model I was
trying to work in.

When taking a closer look at the error "XML parse error..." it appears
that this is something Microsoft could fix. When the web service call
is attempted apperently one of class library objects attempts to
locate a .config file for the current Assembly, if there isn't one,
that's usually no problem, but in the scenario I was working in the
object checking this was throwing an exception because
"myapp.exe?name=johnage=25.config" isn't a valid file name. That's my
guess anyway.




Thanks for you help.
 

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top