NetFwTypeLib and ComElevation dllhost fails to exit
- I am using the comelevation sample from the vistabridge library in the windows sdk to elevate a .net class I exported to a com typelib.
To demonstrate what I have done consider something like this:
When I create my elevated com object and change the value of the property, all is well. When I do the same and call the function, it works but the dllhost process fails to exit. I am calling Marshal.ReleaseComObject on my elevated class. I narrowed the problem down to: Any time I iterate through the INetFwPolicy2.Rules the dllhost process fails to exit. In the above codeblock the function calls Marshal.Release... on each rule, I have tried without this call as well to no avail.class Firewall:IDisposable { INetFwPolicy2 policy = (INetFwPolicy2)Activator.CreateInstance(...); bool FirewallEnabled { get { return policy.get_FirewallEnabled(profileType2); } set { policy.set_FirewallEnabled(profileType2, value); } } void EnableRule(string group, string ruleName, bool enable) { IEnumerator enumerator = null; try { enumerator = this.policy.Rules.GetEnumerator(); while (enumerator.MoveNext()) { INetFwRule iNetRule = (INetFwRule)enumerator.Current; if (string.Equals(iNetRule.Grouping, group, StringComparison.OrdinalIgnoreCase)) { if (string.Equals(iNetRule.Name, ruleName, StringComparison.OrdinalIgnoreCase)) { iNetRule.Enabled = enable; Marshal.ReleaseComObject(iNetRule); break; } } Marshal.ReleaseComObject(iNetRule); } } finally { if (enumerator is IDisposable) { (enumerator as IDisposable).Dispose(); } } }
public void Dispose()
{
Marshal.ReleaseComObject(policy.Rules);
Marshal.ReleaseComObject(policy);
}}
Any thoughts?
1000001 1100001 1110010 1101111 1101110 100000 1000001 1110011 1101000 1100101 1110010- Edited byelement109 Thursday, October 22, 2009 8:24 AMForgot to mention IDisposable
Answers
- Hi element109:
This forum is to support questions on Open Specifications technical interoperability scenarios.
There are very helpful communities of .Net developers on the MSDN that may assist you with your solution. I suggest you post your question on one these forums at the following link:
http://social.msdn.microsoft.com/Forums/en-US/category/netdevelopment
Regards, Obaid Farooqi- Marked As Answer byObaid FarooqiMSFT, ModeratorThursday, October 22, 2009 4:58 PM
All Replies
- Hi element109:
This forum is to support questions on Open Specifications technical interoperability scenarios.
There are very helpful communities of .Net developers on the MSDN that may assist you with your solution. I suggest you post your question on one these forums at the following link:
http://social.msdn.microsoft.com/Forums/en-US/category/netdevelopment
Regards, Obaid Farooqi- Marked As Answer byObaid FarooqiMSFT, ModeratorThursday, October 22, 2009 4:58 PM
- Thanks Obaid, I was not sure if this was the correct forum or not. I should note that I selected this forum from the list of forums on the msdn website. Maybe the forums could benefit from some way of funneling people to the correct forum. From the title I was under the impression this forum was for Intereop programming technical questions. Sorry for my mistake. I don't suppose you could be persuaded to move my thread to the correct forum?
1000001 1100001 1110010 1101111 1101110 100000 1000001 1110011 1101000 1100101 1110010 - I have moved the thread to here:
http://social.msdn.microsoft.com/Forums/en-US/clr/thread/0fa5b971-f128-4f06-8560-59a26a1bf058
1000001 1100001 1110010 1101111 1101110 100000 1000001 1110011 1101000 1100101 1110010


