This message was discovered on microsoft.public.dotnet.framework.windowsforms.controls.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
| bryme.NOSPAM@hotmail.com |
So, we're using the PropertyGrid control in some of our project and we've found a show stopping bug (at least for us). Our scenario is that we develop applications for internal customers and our policy is to distribute the applications as controls hosted in Internet Explorer (similar to VB6 ActiveX controls). We've been able to create and distribute applications designed at such with out incident and have several applications in production. We are also using the PropertyGrid control in some of our applications that required configuration of job processing data and user information. We've been able to get our applications that include the PropertyGrid to run hosted in Internet Explorer by giving the control a strong name and setting the security for that strong name to allow FullTrust. The PropertyGrid works as expected for simple objects, but we have a number of problems when we try to extend the object behavior.
Expandable properties, Custom TypeConverters, Custon UIEditors, DesignerHosts, and DesignerVerbs do not work as expected when the control in question is hosted in Internet Explorer. <OBJECT id='Controller' classid='JobController.dll#JobController.Runner'></OBJECT>
If the same control is placed into a Windows Application and run from a link in Internet Explorer, the control runs as expected. <a href="Controller.exe">Test Me Here!</a>
Hosted in Internet Explorer, the following happen: 1. Expandable properties are no longer expandable and are read-only 2. Custom UIEditor ellipsis button is not available 3. Custom Designer cannot be returned from SelectedObject
Thinking that this may be due to the fact the the control needs to be sited on an actual form, we've also made a new control load a form that has the control in question from a command button. This still produces a control where the proertygrid doesn't fully support Expandable properties, Custom TypeConverters, Custon UIEditors, DesignerHosts, and DesignerVerbs.
We've tried asserting permissions in our control (for the OnSelectedObject event) for every conceivable combination we could think of including reflection and security.
We've even tried removing .Net Security from our test machine temporarily (CASPOL -s OFF) to see if this is due to .Net Security interfering with code execution. The only things left we can think of that could be causing the problem would be:
1. Internet Explorer 2. the PropertyGrid 3. Our code (but it works properly when the control is hosted in an executable, just not IE)
So, we'd appreciate any and all help that anyone could provide.
Thanks.
Brian
|
|
|
| |
|
| |
| |
| Ying-Shen Yu[MSFT] (VIP) |
Hi Brian,
From your description, you have met several issues when using a propertyGrid hosting in Internet Explorer. I'm not clear what's the meaning of the "not fully support"? In my test, I created a Usercontrol , put a datagrid control and a PropertyGrid control onto it, set the SelectedObject to the datagrid control. I browsed the control in IE, it seems works correct to me. You may try this scenarion too, and let me know where is the problem.
For DesignerHost, and DesignerVerb, Did you created a designer host in your app? these features needs design-time support, they are not available when your control is instantiated as run-time.
If you still have problem on this issue, please let me know more detail about this issue, If you have a simple repro project for this issue, please send a copy to me, I'd like to take a look at it. Thanks!
Best regards,
Ying-Shen Yu [MSFT] Microsoft Online Partner Support Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties and confers no rights. This mail should not be replied directly, "online" should be removed before sending.
|
|
|
| |
|
|
| |
| |
| Brian Young |
Ying-Shen,
Yes, I was able to confirm that your example does indeed work. My problem is that if my object has custom properties that implement UITypeConverters, UIEditors, and such, so this doesn't work. The property is rendered readonly and the custom code does not work in IE. A regular executable, however will work properly. For the DesignerHost and DesignerVerb, I've implemented IDesignerHost and the other required supporting interfaces to get this to work properly, yet again only in an executable. Hosting the custom control in IE will return nothing when I try to create an instance of the designer from the object.
I do have a project where I can reproduce this issue, however, it it a bit far from simple. WOuld it be best to email this project to you email?
Brian
""Ying-Shen Yu[MSFT]"" <Click here to reveal e-mail address> wrote in message news:Click here to reveal e-mail address... [Original message clipped]
|
|
|
| |
|
|
| |
| |
| Ying-Shen Yu[MSFT] (VIP) |
Hi Brian,
Ok, I'd like to take a look at that sample project first, you may send the sample project to the e-mail address in the newsgroup post header. Note, please follow the instructions in my signature before sending. If it is possible, please send me a relative simple project ,since I only want to see the problem and simple project will save time for both of us. Thanks!
Best regards,
Ying-Shen Yu [MSFT] Microsoft Online Partner Support Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties and confers no rights. This mail should not be replied directly, please remove the word "online" before sending mail.
|
|
|
| |
|
|
| |
| |
| Ying-Shen Yu[MSFT] (VIP) |
Hi Brian,
I apologize for the long delay, since I was researching on your sample code. This is actually not a bug in PropertyGrid, it is caused by the IE Host mechanism for .NET control. The problem is actually caused by IEHost failed to resolve the assembly reference, if you handle the Appdomain.AssemblyResolve event , and show the requested assembly name, You will see this event handler is get fired before the NullReferenceException thrown out. normally, CLR assembly binding mechanism will try looking for certain assembly in GAC or the same directory as the program. But in IEHost scenario, download assembly is not saved in either place, so CLR couldn't find it in dynamic instantiate an object.
To workaround this problem , you may handle the assembly resolve event and help CLR get the reference <code> Private Function AssemblyResolve_EventHandler(ByVal sender As System.Object, ByVal e As System.ResolveEventArgs) As System.Reflection.Assembly 'need test if it is failed at assembly resolve 'MsgBox("Hello need resolve!")
'return the corresponding assembly 'We don't care about the type, but just use them to get the correct executing assembly 'Note, here I assume you will not load the an assembly with the same name but with a different version If (e.Name.StartsWith("PGHost")) Then Return System.Reflection.Assembly.GetAssembly(GetType(PGHost.DescriptorAttribute)) End If
If (e.Name.StartsWith("WinTest")) Then Return System.Reflection.Assembly.GetAssembly(GetType(WinTest.a)) End If
'we still have some unresolved assembly?show some debugging info MsgBox(e.Name) MsgBox(System.Reflection.Assembly.GetExecutingAssembly.ToString) MsgBox(System.Reflection.Assembly.GetCallingAssembly.ToString) MsgBox(System.Reflection.Assembly.GetEntryAssembly.ToString) End Function </code>
How about the expandableObject issue? I'll go on research on for that issue If you still have problem on this designer issue please feel free to reply this thread. Thanks!
Best regards,
Ying-Shen Yu [MSFT] Microsoft community Support Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties and confers no rights. This mail should not be replied directly, please remove the word "online" before sending mail.
|
|
|
| |
|
|
| |
| |
| Ying-Shen Yu[MSFT] (VIP) |
Hi Brian,
I tested the expandable object after applying this workaround, it seems the expandable is working fine in my test. I guess it's also caused by the previous assembly resolve failure, If it doesn't work for you please let me know. Thanks!
Best regards,
Ying-Shen Yu [MSFT] Microsoft community Support Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties and confers no rights. This mail should not be replied directly, please remove the word "online" before sending mail.
|
|
|
| |
|
|
| |
| |
| Brian Young |
Ying-Shen,
Thank you for your help. This sounds like it would do the trick for me. It is awesome that I can now get it to behave properly!
A general question on this same line is regarding any custom control hosted in Internet Explorer. Would you suggest that we apply this code to any of our internal projects that create WinForm controls? My concern is not all the developers in my organization would know this information and I would rather correct this by providing them with this info by updating our enterprise templates to include this code. I don't see any damage that this could do, but perhaps you might have some thoughts about this?
Thanks.
Brian
|
|
|
| |
|
| |
| |
| Ying-Shen Yu[MSFT] (VIP) |
Hi Brian,
You needn't put this code into every custom control. How about handle this event in your Grid Control? of course we need change the code a bit. I uses a loop here for simplicity, since we normally only have several assemblies (less than 10) in an appdomain. for a better implmentation you may take advantage of the BinarySearch method on the Assembly Array. So since we can wrap it into the Grid, I think we needn't update the enterprise templates, right?
Hope it helps. :) <code> 'Add Handler in Initialize method Private Function AssemblyResolve_EventHandler(ByVal sender As System.Object, ByVal e As System.ResolveEventArgs) As System.Reflection.Assembly 'need test if it is failed at assembly resolve 'MsgBox("Hello need resolve!")
'return the corresponding assembly 'We don't care about the type, but just use them to get the correct executing assembly
Dim asms() As System.Reflection.Assembly = System.AppDomain.CurrentDomain.GetAssemblies() For i As Integer = 0 To asms.Length If asms(i).FullName = e.Name Then Return asms(i) End If Next
'in case no asm was found, seems the requested assembly hasn't been loaded MsgBox("requested assembly: " + e.Name) MsgBox(System.Reflection.Assembly.GetExecutingAssembly.ToString) MsgBox(System.Reflection.Assembly.GetCallingAssembly.ToString) MsgBox(System.Reflection.Assembly.GetEntryAssembly.ToString)
End Function </code>
Best regards,
Ying-Shen Yu [MSFT] Microsoft community Support Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties and confers no rights. This mail should not be replied directly, please remove the word "online" before sending mail.
|
|
|
| |
|
|
| |
| |
| Brian Young |
Ying-Shen,
So, this seems to work for me. I'll have to run a few more test scenarios, but adding that snippet of code to my inherited propertygrid control fixes the IE problem. Thanks much for your help.
Brian
|
|
|
| |
|
|
| |
|
|
|
|
|
|
|
|
| |
| scorpion74 |
Hello,
This problem is similar to the one I read in microsoft discussion forum by Brian Young.I am also trying to attempt similar functionality as his, the only difference is that I am calling a method of usercontrol to set it's height and width properties as of browser's height and width property.Below is my code and u'll have better idea.
<body><script language="javascript"> function resizeWindow() { w = document.body.clientWidth; h = document.body.clientHeight ;
document.objUserControl1.UserControlResize(w,h);
} </script><OBJECT id="objUserControl1" classid="client/bin/ManageNavigation.dll#ManageNavigation.UserControl1" VIEWASTEXT></OBJECT></body>
//UserControl1.cs
public void UserControlResize(int w, int h) { this.Size = new System.Drawing.Size(w, h);
}
The above code works fine for all the other controls I add to usercontrol.But as soon as I add PropertyGrid control and set it's Dock property to Fill and run the application, it fails at 'document.objUserControl1.UserControlResize(w,h);' this line. If anybody knows the problem then please let me know.
Thanking you in anticipation.
|
|
|
| |
|
| |
| |
| Ying-Shen Yu[MSFT] (VIP) |
Hi,
The previous issue was caused by type load failure, and it doesn't seem the cause of this issue, to further investigate your issue, you may handle the AppDomain.UnhandledException and get a stack trace of this problem, it would give more information for the problem. Thanks!
Best regards,
Ying-Shen Yu [MSFT] Microsoft Community Support Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties and confers no rights. This mail should not be replied directly, please remove the word "online" before sending mail.
|
|
|
| |
|
|
| |
|
|
|
|
|
|