Web client component won't work when strong-named.

L

Lowell

I have a web page which downloads a component with an <OBJECT> tag. The HTML looks something like the following:

<OBJECT id="NewObj" classid="http:/VirDir/CompName.dll#THEYAS.DEPT.ProjectName.CompName" VIEWASTEXT><PARAM NAME="Param1" VALUE="Value1"></OBJECT>

It works just fine when the component is not strong-named. But once I change the "AssemblyInfo.cs" file to make the component strong named (by giving it value for the "AssemblyKeyFile" attribute) and recompile, the same component won't load. (The initial GUI won't come up--I just get a little tiny "default" icon in the upper left corner of the area where the "CompName" component should be.)

I used "mscorcfg.msc" to add a code group and the "Membership Condition" is "URL" and the "URL:" is "http://servername/*";.

I would like to make this component strong-named for better security (changing that "Membership Condition" to a strong-name) and I want to have it reference other strong-named components--including the Office XP PIAs.

So, how do I make this work with strong-named assemblies?

Thanks!

Lowell
 
J

Jeffrey Tan[MSFT]

Hi,

Thank you for using MSDN Newsgroup!
My name is Jeffrey, and I have reviewed your post, I will do some research
on your issue.
I will reply to you ASAP. Thanks for your understanding.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
J

Jeffrey Tan[MSFT]

Hi,

Based on my understanding, you create an asp.net web form application,
which consume a Windows Form component. But after specify strong name and
re-compile, your control appear in designer a default error icon.

=======================================
I have writen a sample project, if I specify strong name, my application
works well.
Because if you do not use strong name your control works well, I think your
assembly should have no problem. After you specify the .snk file in
AssemblyKeyFile attribute and compile, does the compile succeed? Can your
the compiler find your .snk file?

If the compiler can find the .snk file, I think the problem should be the
access permission. As you specify a "http://servername/*" code group for
your application, what permission set do you sepcify? I think you can try
the "full trust" permission for your application.

Also, your application may meet many conditions types in different code
groups. So it has several permission sets. The configuration will choose
the intersection of these permission sets. So you should check all the
permission sets in different code groups, ensure that the minimal
intersection of all the permission sets are fully enough for your access.

========================================
Thanks for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
T

theyas

I'm not sure I understand what you are doing. I am using
Active Server Pages. But the Windows Form component is
actually "consumed" on the client side--not on the server
side.

When I recompile (whether strong-named or not) I have to
copy the resulting DLL to the location of the .ASPX page.
So, I compile (not strong-named), copy the compiled DLL to
the location of the .ASPX page (so that the resulting HTML
<OBJECT> tag can refer to it), and then run my app. Then,
I change the assemblyinfo.cs file to make my app strong-
named, delete a character inside a comment to change the
main .cs file, compile, copy the DLL to the location of
the .ASPX page, and run my app again. The second time, it
does not work.

I've also looked at the permissions in the mscorcfg.msc.
They are the default permissions except for the permission
set and code group that I added for this application. The
new Permission Set adds the following
permissions: "Environment Variables", "File Dialog", "File
IO", "Isolated Storage
File", "Reflection", "Registry", "Security", "User
Interface", "DNS", "Printing", "Event Log", "Web Access",
and "Directory Services". The new Code Group is the only
additional code group under "LocalIntranet_Zone". I've
also tried a client system (using the development system
as the server) and I get the same results. On the client,
I have several code groups under "LocalIntranet_Zone"
which have membership conditions to match the servername
and the full DNS name of the server.
(I.e. "http://server/*" and "http://server.domain.net/*")
As I said, same results.

One more interesting piece of data. WHETHER IT WORKS OR
NOT, the log file shows the same thing. First a
successful (200 error code) GET request
for "/AppWeb/AppWebClient.aspx <get params>" then a
successful GET request for "/AppWeb/AppUI.dll" followed by
unsuccessful (404 error code) GET requests for the
following (in order):

/AppUI.DLL
/AppUI/AppUI.DLL
/bin/AppUI.DLL
/bin/AppUI/AppUI.DLL
/AppUI.EXE
/AppUI/AppUI.EXE
/bin/AppUI.EXE
/bin/AppUI/AppUI.EXE

Now, if it works (i.e. is not strong-named), then there
follows a POST request to my data service (yes,
my "AppUI.dll" gets some info from the database as it
comes up), followed, bizarrely, by the same 8 unsuccessful
get requests!

Thanks in advance for the help.

Lowell
 
J

Jeffrey Tan[MSFT]

Hi theyas,

Thanks for your feedback.
What is your dll assembly function? Is it winform based control? Also, in
design-time, what is the appearance of your <object>? Does it show an error
icon or work well?

=======================================
I think to figure your problem, you may first create a new project to find
out if you can reproduce it out. Once you can reproduce out for me, I can
help you more well.

Please check the article below:
http://www.codeproject.com/cs/miscctrl/htmlwincontrol.asp

This article uses almost the same logic as you. You can first download it
source code and use strong name to find if your problem can reproduce.

I use strong name like this:
1). Use sn.exe -k test.snk
2). Copy test.snk to your application's bin directory
3). Set the AssemblyKeyFile("") like this:
4). Recompile your project.

========================================
I am waiting to get a reproduce steps from you. I will try my best to help
you.
Have a nice day.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
L

Lowell

Jeffrey,

Thanks for keeping on looking up stuff while waiting for my reply. You've got the right idea. I didn't try that particular code sample because I got together something a little closer to what I need. I've got a 59KB Zip file which has a full solution in it. Basically, I did a takeoff on the "Walkthrough: Creating a Distributed Application" which creates a Web Data Service, a Window program that uses that data service and a Web Application that also uses it. (In the example, it is called a "WebClient" even though it is a Server-based app!) It uses the "pubs" sample database that is automatically installed with SQL server, so if you have a default install of SQL Server, IIS, and Visual Studio on the same machine, you can run it. The other advantage of this is that it doesn't appear to need any "mscorcfg.msc" permissions tweaking to run--and fail (at least if everything is on the devlopment server).

What I did was create the Web Data Service just like in the walkthrough. I also created the Web Application like the walkthrough (except I called it "AuthorsWebApp" instead of "AuthorsWebClient"). Then, where the walkthrough created an Executable, I created a UserControl (in "AuthorsControl") with the main functionality. Then, I created another executable (in "AuthorsWinClient") which used the UserControl. Finally, I created a web page which used the Usercontrol as an "ActiveX"-type downloaded object (in "AuthorsWebClient"). You can get the zip file, unzip it (it creates a "Authors" directory with everything else under that), read the "ReadmeFirst.txt" to see how to set up your system, compile it and run it. (You will need to compile since I took all the compiled stuff out to save space.)

The readme also talks about how to reproduce the issue. My suggestion is to follow the steps in the "ReadmeFirst.txt" file until you get everything working. (You may need to do more to get the data connection set up than I talked about in the "ReadmeFirst.txt", but I figure that whatever it is, you'll be better able to handle it than if I try to anticipate your problems. If worst comes to worst, redo the Data Server part of the Walkthrough--it's at:

http://msdn.microsoft.com/library/d...atingDistributedWebApplicationWalkthrough.asp

Finally, here is the URL to the file I keep talking about. The browser-based newsreader client doesn't seem to do attachments and I don't want to use Outlook Express.

http://ix.netcom.com/~yasny/theyas/Authors.zip

Lowell

----- \"Jeffrey Tan[MSFT]\" wrote: -----


Thanks for your feedback.
What is your dll assembly function? Is it winform based control? Also, in
design-time, what is the appearance of your <object>? Does it show an error
icon or work well?

=======================================
I think to figure your problem, you may first create a new project to find
out if you can reproduce it out. Once you can reproduce out for me, I can
help you more well.

Please check the article below:
http://www.codeproject.com/cs/miscctrl/htmlwincontrol.asp

This article uses almost the same logic as you. You can first download it
source code and use strong name to find if your problem can reproduce.

I use strong name like this:
1). Use sn.exe -k test.snk
2). Copy test.snk to your application's bin directory
3). Set the AssemblyKeyFile("") like this:
4). Recompile your project.

========================================
I am waiting to get a reproduce steps from you. I will try my best to help
you.
Have a nice day.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
S

Sean Shi

Hi Lowell,

I looked at the issue briefly and I just wonder whether you have the simple
windows form control available. If it is, can you just send me that control
( the strong-named dll only) and the .html page you used? You should be
able to see this control at least if the control is put in the right
directory. I think the easiest way is to test a very simple con trol in
different environment. you send the .dll and .html file directly to me.


Thanks,

Sean Shi (MSFT)
Microsoft Internet Explorer Support Professional

The posting is provided "AS IS" with no warranties, and confering no rights.
 
L

Lowell

Hi Sean,

Done. (Since I'm using an alias here, I hope the email comes through.) Thanks!

Lowell

----- Sean Shi (MSFT) wrote: -----

Hi Lowell,

I looked at the issue briefly and I just wonder whether you have the simple
windows form control available. If it is, can you just send me that control
( the strong-named dll only) and the .html page you used? You should be
able to see this control at least if the control is put in the right
directory. I think the easiest way is to test a very simple con trol in
different environment. you send the .dll and .html file directly to me.


Thanks,

Sean Shi (MSFT)
Microsoft Internet Explorer Support Professional

The posting is provided "AS IS" with no warranties, and confering no rights.
 
L

Lowell

Bingo!! That was it!! As the article says, you also need to add the "using System.Security;". (Some people don't follow links that they should.... :-

THANKS!!

Lowel

----- Sean Shi (MSFT) wrote: ----

Found out it is by design, the solution is to add the following line of
code into the AssemblyInfo.cs

[assembly: AllowPartiallyTrustedCallers

For detail, check out
http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q814669


Thanks

Sean Sh
Microsoft Internet Explorer Support Professional

The posting is provided "AS IS" with no warranties, and confering no rights
 

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,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top