.NET Base Class Library ForumDiscuss the Base Class Library, design, and best practice issues of managed code: Collections, Diagnostics, I/O, Registry, Globalization, Reflection, and Text.© 2009 Microsoft Corporation. All rights reserved.Wed, 25 Nov 2009 21:10:57 Z7ea22a5b-087d-4187-b5fc-182712ac450fhttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/f5a59eac-4a3e-4417-99a8-83d4a6a9e41dhttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/f5a59eac-4a3e-4417-99a8-83d4a6a9e41dNick Duanehttp://social.msdn.microsoft.com/Profile/en-US/?user=Nick%20DuaneSeems like some methods of IEnumerator<T> should throw ObjectDisposedException<p>I'm using .NET 2.0 and looking at the docs for IEnumerator&lt;T&gt;.  One part of the docs say that Dispose() method does not depend on T and only appears in non-generic interface.  While I'll agree it's not dependent on T, it is only on the generic interface.  IEnumerator does not derive from IDisposable only IEnumerator&lt;T&gt; does.  Since an object implementing IEnumerator&lt;T&gt; implements IDisposable shouldn't some of the methods of IEnumerator&lt;T&gt; and its IEnumerator methods throw an ObjectDisposedException?  Looking at the docs none of them do.<br/><br/>Thanks,<br/>Nick</p>Wed, 25 Nov 2009 21:10:53 Z2009-11-25T21:10:57Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/d59a9d10-37b5-4a0a-9b50-657c5fdd0d77http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/d59a9d10-37b5-4a0a-9b50-657c5fdd0d77Leonid Rhttp://social.msdn.microsoft.com/Profile/en-US/?user=Leonid%20Rretry attributeHi , <div>Is it possible to create an attribute which can be applied to a method and will do a retry in case of operation failure ? </div> <div><br/></div> <div>for example : </div> <div><br/></div> <div>[Retry(2)]</div> <div>void MyMethod();</div> <div><br/></div> <div><br/></div> <div>in case of exception, operation will be retried twice . if after 2 times exception still will be thrown- so it will be re thrown. </div> <div><br/></div> <div><br/></div>Wed, 25 Nov 2009 19:51:25 Z2009-11-25T21:01:04Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/cf5fb569-8984-4c4c-a4c6-5e4b5e2ebfe3http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/cf5fb569-8984-4c4c-a4c6-5e4b5e2ebfe3John Aschenbrennerhttp://social.msdn.microsoft.com/Profile/en-US/?user=John%20AschenbrennerHelp with Aggregate for Dynamic Type Object Mapper classHi all,<br/><br/>I have created a Object Mapper class using the System.Reflection.Emit namespace.  It is a necessity that I create some type of dynamic types to contain the data that is contained in the XML files that I am using.<br/><br/>I have this working in that given an XML file based on an XSD of a given type I can build a dynamic type that contains all the data as properties and an overload of the ToString method that returns the name of the test data being represented.<br/><br/>Now I have a requirement to return aggregates of the numeric data values given a collection of the above.  Perhaps some code will give you an idea of what I am trying to emit.  I did use ildasm to look at the IL and it appears to contain IL that is above my pay grade to produce.  I have thought about using the code dom or reflection to solve the same problem but am looking for a great suggestion from you folks out there.<br/><br/>At any rate here is a sample of what the aggregate class should look like that needs to be created dynamically.<br/><br/> <pre lang="x-c#"> public class _2chTests : List&lt;_2ch&gt; { public _2chTests() { } public _2chTests(IEnumerable&lt;_2ch&gt; tests) : base(tests) { } public enum Function { Mean, StandardDeviation, Sum, Max, Min, Number }; private StatisticalMath.Function functionType = StatisticalMath.Function.Mean; #region Public Properties // can be Mean, Standard Deviation, Sum, Min, Max or Count public string Function { get { return &quot;Mean&quot;; } } public string Session { get { return string.Empty; } } public string Run { get { return string.Empty; } } public string Date { get { return string.Empty; } } public string Time { get { return string.Empty; } } // functionType is an enum representing a given StatisticalMath function public double MeanRTCorr { get { return StatisticalMath.AggregateFunction(functionType, from m in this select m.MeanRTCorr); } } public double StDevRTCorr { get { return StatisticalMath.AggregateFunction(functionType, from m in this select m.StDevRTCorr); } } public double NumTrials { get { return StatisticalMath.AggregateFunction(functionType, from m in this select m.NumTrials); } } public double NumCorr { get { return StatisticalMath.AggregateFunction(functionType, from m in this select m.NumCorr); } } public double NumInc { get { return StatisticalMath.AggregateFunction(functionType, from m in this select m.NumInc); } } public double NumLapse { get { return StatisticalMath.AggregateFunction(functionType, from m in this select m.NumLapse); } } public double PercCorr { get { return StatisticalMath.AggregateFunction(functionType, from m in this select m.PercCorr); } } public double PercLapse { get { return StatisticalMath.AggregateFunction(functionType, from m in this select m.PercLapse); } } public double Speed { get { return StatisticalMath.AggregateFunction(functionType, from m in this select m.Speed); } } public double Throughput { get { return StatisticalMath.AggregateFunction(functionType, from m in this select m.Throughput); } } public double LegacyThru { get { return StatisticalMath.AggregateFunction(functionType, from m in this select m.LegacyThru); } } public double MinRTCorr { get { return StatisticalMath.AggregateFunction(functionType, from m in this select m.MinRTCorr); } } public double MaxRTCorr { get { return StatisticalMath.AggregateFunction(functionType, from m in this select m.MaxRTCorr); } } public double MinRT { get { return StatisticalMath.AggregateFunction(functionType, from m in this select m.MinRT); } } public double MaxRT { get { return StatisticalMath.AggregateFunction(functionType, from m in this select m.MaxRT); } } public double NumBad { get { return StatisticalMath.AggregateFunction(functionType, from m in this select m.NumBad); } } public double MedRTCorr { get { return StatisticalMath.AggregateFunction(functionType, from m in this select m.MedRTCorr); } } public double MedRT { get { return StatisticalMath.AggregateFunction(functionType, from m in this select m.MedRT); } } public double MeanRT { get { return StatisticalMath.AggregateFunction(functionType, from m in this select m.MeanRT); } } public double StDevRT { get { return StatisticalMath.AggregateFunction(functionType, from m in this select m.StDevRT); } } #endregion Public Properties } </pre> <br/><br/><hr class="sig">Thanks, -ja Wed, 25 Nov 2009 20:39:25 Z2009-11-25T20:39:25Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/b19bc85b-c145-4fd2-8c5f-9d3cf37a2968http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/b19bc85b-c145-4fd2-8c5f-9d3cf37a2968Ed_Whitehttp://social.msdn.microsoft.com/Profile/en-US/?user=Ed_WhiteWindows 7: reading backup UPS battery status<p>Windows 7 has a &quot;Power Options&quot; configuration available through the Control Panel, and Windows XP has a similar setting. While it makes sense that the battery settings apply to the battery in a laptop, I've learned that they also apply to a backup Uninteruptible Power Supply (UPS) battery that a desktop may be plugged into.  Apparently, in Windows XP there was an option to run a script or program when the UPS battery level falls to a certain level, but this option to run a script was taken out of Vista/Windows 7.  Instead, you can only Hibernate, Sleep, or Shutdown when the battery level falls to a certain percentage using the Power Options.  My problem is that I have a program I've written (in VB.net using VS 2008) that does automatic day trading, and if the electric power goes down and I'm running on batteries with only a few minutes left, I need for my program to learn that and close all outstanding trades before the PC shuts down (merely shutting down or hibernating the PC will leave my trading position exposed).  Since the option to run a script in such cases is no longer available in W7, is there an API, or something in the registry I can read, or something else I can use for my VB program to read the status of the UPS battery and be alerted when the battery level falls to a certain level?</p>Wed, 25 Nov 2009 18:42:29 Z2009-11-25T20:25:05Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/e613b886-8210-4873-815c-05b925105744http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/e613b886-8210-4873-815c-05b925105744George Wanghttp://social.msdn.microsoft.com/Profile/en-US/?user=George%20WangInconsistent type conversionJust found some inconsistency in type conversion of the .NET types. For example: you cannot do:<br/> <pre lang="x-c#">long l = (long)((object)2);</pre> but you can do: <pre lang="x-c#">TypeCode tc = (TypeCode)((object)3);</pre> In the contrary, Convert.ChangeType behaves just the opposite: you can do:<br/> <pre lang="x-c#">Convert.ChangeType(2, typeof(long));</pre> but you cannot do:<br/> <pre>Convert.ChangeType(2, typeof(TypeCode));</pre> I am posting this because I was writing a ITypeConverter inplementation, one of whose functionality is to convert an integer value to a enum, whose actual type is passed in as the targetType parameter. It is frustrating to have to use something nasty like the following:<br/> <pre lang="x-c#">private static T Cast&lt;T&gt;(object o) { return (T)o; }</pre><hr class="sig">Visual Studio 2008 rocks!Wed, 25 Nov 2009 18:48:36 Z2009-11-25T20:10:02Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/d0d06e8f-4b80-4ea9-becf-b419bfa6a3c0http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/d0d06e8f-4b80-4ea9-becf-b419bfa6a3c0gadgalleahttp://social.msdn.microsoft.com/Profile/en-US/?user=gadgalleaReportViewerI have reportviewer that need to be translated at runtime.<br/>Is it possible? How?<br/><br/>Thank youMon, 16 Nov 2009 16:03:36 Z2009-11-25T18:59:16Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/a876e83c-f6de-4da0-939d-611551626fb7http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/a876e83c-f6de-4da0-939d-611551626fb7jithin_sshttp://social.msdn.microsoft.com/Profile/en-US/?user=jithin_ssForm_Closing event while crashing applicationHi,<br/><br/>I have a windows application in c#. I want to execute some code if the application crashes. Form closing event of the application is working only for the main form.<br/>That means, if i have opened any sub forms from the main form, the form closing event of main form is not triggering (if application crashes.). and if i opened only the main form, then the form_closing event is getting executed. Why this is happening? I want to execute my form closing event of my main form every time (if at all i opened subforms).<br/><br/>thanks in advance<br/><br/>jithin Shyam S<br/><br/>Wed, 25 Nov 2009 13:16:24 Z2009-11-25T18:27:58Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/0380a03c-8ddc-4dac-af25-578f8e040ff1http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/0380a03c-8ddc-4dac-af25-578f8e040ff1sn75http://social.msdn.microsoft.com/Profile/en-US/?user=sn75How do I get value of autogenerated column in MS SQLI have a table with column with autogenerated values. After I add a new row, how do I get the autogenerated value of the given column of this row?Wed, 25 Nov 2009 17:52:32 Z2009-11-25T18:23:15Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/50a48431-5c24-41d0-9485-c21fef31849ahttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/50a48431-5c24-41d0-9485-c21fef31849at sswhttp://social.msdn.microsoft.com/Profile/en-US/?user=t%20sswGetEntryAssembly and Assembly.LoadFromI am loading an assembly with a call to Assembly.LoadFrom.  I am surprised when my code failed when the call to GetEntryAssembly returned NULL.  The hosting process is a WinForms .NET application.  The assembly is loaded in a domain created with AppDomain.CreateDomain.  What am I missing?  GetEntryAssembly mentions it will return null if hosted by a unmanaged application but this isn't the case here.<br/> <br/> Regards,Mon, 16 Nov 2009 15:19:48 Z2009-11-25T17:17:59Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/f2e67586-f795-48e2-a87b-81a92ae04663http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/f2e67586-f795-48e2-a87b-81a92ae04663Godeffroyhttp://social.msdn.microsoft.com/Profile/en-US/?user=GodeffroyHow to remove duplicate links URL in a list of URL ?Hi,<br/> I would like to identify duplicate in a list of links. <br/> <br/> For example I would like to transform link such as http://domain.com//physical.aspx into :<br/>                                                                    http://domain.com/physical.aspx<br/> <br/> For example the 2 above are duplicates because they indicate the same website(valid URL)<br/>  but the strings are differents.<br/> <br/> How to make sure there is no duplicate in a list of links like this :<br/> http://domain.com//physical.aspx<br/> http://domain.com/physical.aspx<br/> http://domain.com///physical.aspx<br/> <br/> I could have much more complex links like :<br/> http://domain.com//test////physical.aspx<br/> http://domain.com/test/physical.aspx<br/> http://domain.com//test/physical.aspx<br/> <br/> etc...<br/> <br/> <br/> How to get rid of such duplicates ?<br/> <br/> Thanks<br/> <br/> <br/> <br/> ThanksWed, 25 Nov 2009 16:54:13 Z2009-11-25T17:11:44Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/93fe0962-be71-49c5-8238-4b030c58acf9http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/93fe0962-be71-49c5-8238-4b030c58acf9timi2shoeshttp://social.msdn.microsoft.com/Profile/en-US/?user=timi2shoesEmbed Fonts C# .Net CompactI am trying to find out how to embed a font with .net compact or if it is even possible. Thank YouWed, 25 Nov 2009 15:50:22 Z2009-11-25T16:31:33Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/79f2905f-a60f-4f6e-9aab-eafc46c602e5http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/79f2905f-a60f-4f6e-9aab-eafc46c602e5Godeffroyhttp://social.msdn.microsoft.com/Profile/en-US/?user=GodeffroyCrashed sporadic when using WebResponse response = req.GetResponse();. Hi all,<br/> <br/> I am downloading several url links with the method DownloadData.<br/> Unfortunately it crashed after using this function few times.<br/> It crashed at the line WebResponse response = req.GetResponse();.<br/> It hangs for a while and then send an exception &quot;The operation has timed out&quot;.<br/> The URL tested are ok because i can access as many times as i want from internet explorer.<br/> I am online all the time too. Why is it crashing like this ?<br/> <br/> Why it crashed like this ? SHould I use HttpWebResponse and HttpWebRequest instead ?<br/> <br/> <pre> public string DownloadData(string url)<br/> {<br/> byte[] downloadedData = new byte[0];<br/> try<br/> {<br/> WebRequest req = WebRequest.Create(url);<br/> <strong> WebResponse response = req.GetResponse();<br/> </strong> Stream stream = response.GetResponseStream();<br/> byte[] buffer = new byte[1024];<br/> int dataLength = (int)response.ContentLength;<br/> MemoryStream memStream = new MemoryStream();<br/> while (true)<br/> {<br/> int bytesRead = stream.Read(buffer, 0, buffer.Length);<br/> Application.DoEvents();<br/> <br/> if (bytesRead == 0)<br/> { <br/> break;<br/> }<br/> else<br/> {<br/> memStream.Write(buffer, 0, bytesRead);<br/> }<br/> }<br/> downloadedData = memStream.ToArray();<br/> stream.Close();<br/> memStream.Close();<br/> }<br/> catch (Exception)<br/> {<br/> MessageBox.Show(&quot;There was an error accessing the URL.&quot;);<br/> }<br/> return ASCIIEncoding.ASCII.GetString(downloadedData);<br/> }</pre> <br/> <br/> <br/> ThanksWed, 25 Nov 2009 16:00:36 Z2009-11-25T16:20:11Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/603bf85c-a499-40c5-a6bd-6fee9aa09a1ehttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/603bf85c-a499-40c5-a6bd-6fee9aa09a1esisvis Eclipsyshttp://social.msdn.microsoft.com/Profile/en-US/?user=sisvis%20EclipsysIs Enumaration by multiple threads on Dictionary<TKey,TValue> class threadsafe?Can multiple threads Enumarate Same Generic Dictionary object concurrently?<br/><br/>Please once go through following code sample. In following code LoopThroughDictionary method is called on multiple threads concurrently. Will it cause problem? <br/><strong><br/>Summary : Enumaration from multiple threads on Generic Dictionary is threadsafe if Dictionary is not modified (add,remove operations are not done) during this time?<br/><br/></strong>MSDN says, <br/><br/>A <span class=selflink>Dictionary<span class=cs>&lt;</span><span class=vb>(Of </span><span class=cpp>&lt;</span><span class=nu>(</span>TKey, TValue<span class=cs>&gt;</span><span class=vb>)</span><span class=cpp>&gt;</span><span class=nu>)</span></span> can support multiple readers concurrently, as long as the collection is not modified. <strong>Even so, enumerating through a collection is intrinsically not a thread-safe procedure.</strong> In the rare case where an enumeration contends with write accesses, the collection must be locked during the entire enumeration. To allow the collection to be accessed by multiple threads for reading and writing, you must implement your own synchronization.<br/> <pre lang="x-c#">using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; namespace ConsoleApplication2 { class Program { //static dictionary static Dictionary&lt;string, MyTestClass&gt; testDictionary; static void Main(string[] args) { //Fill dictionary testDictionary = new Dictionary&lt;string, MyTestClass&gt;(); for (int i = 0; i &lt; 100; i++) { MyTestClass temp = new MyTestClass(i); testDictionary.Add(i.ToString(), temp); } //Create delegate ParameterizedThreadStart thstartDelegate = new ParameterizedThreadStart(LoopThroughDictionary); //Create threads Thread t1 = new Thread(thstartDelegate); Thread t2 = new Thread(thstartDelegate); Thread t3 = new Thread(thstartDelegate); Thread t4 = new Thread(thstartDelegate); //Start threads t1.Start(10); t2.Start(20); t3.Start(30); t4.Start(40); Console.ReadLine(); } //this method will be called on threads and it simply enumarates the dictionary //Question: is this method threadsafe? static void LoopThroughDictionary(object delay) { int threadDelay = (int)delay; foreach (KeyValuePair&lt;string, MyTestClass&gt; entry in testDictionary) { entry.Value.ShowMyStatus(); Thread.Sleep(threadDelay); } } } class MyTestClass { public int status; public MyTestClass(int i) { status = i; } public void ShowMyStatus() { Console.WriteLine(&quot;Thread ID : &quot; + Thread.CurrentThread.ManagedThreadId + &quot; status : &quot; + status); } } } </pre>Tue, 24 Nov 2009 12:59:36 Z2009-11-25T15:33:12Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/1bfca68d-4e27-4269-89cb-fb7de4b4afefhttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/1bfca68d-4e27-4269-89cb-fb7de4b4afefJoeyWanghttp://social.msdn.microsoft.com/Profile/en-US/?user=JoeyWangClipboard operation and MemoryStream lead to corrupt memoryI write a program, but happen System.AccessViolationException.<br/>the code as below<br/><span style="font-size:x-small"><font size=2> <p>System.Windows.Forms.</p> </font></span> <p><span style="font-size:x-small;color:#2b91af">IDataObject</span><span style="font-size:x-small"> dataObject = System.Windows.Forms.</span><span style="font-size:x-small;color:#2b91af">Clipboard</span><span style="font-size:x-small">.GetDataObject();<br/></span><span style="font-size:x-small">dataObject.GetDataPresent(clipFormatName);<br/></span><span style="font-size:x-small;color:#2b91af">Object</span><span style="font-size:x-small"> data = dataObject.GetData(clipFormatName);<br/>System.IO.</span><span style="font-size:x-small;color:#2b91af">MemoryStream</span><span style="font-size:x-small"> dataStream = data </span><span style="font-size:x-small;color:#0000ff">as</span><span style="font-size:x-small"> System.IO.</span><span style="font-size:x-small;color:#2b91af">MemoryStream</span><span style="font-size:x-small">;<br/>data = </span><span style="font-size:x-small;color:#0000ff">null</span><span style="font-size:x-small">;<br/>dataStream.Dispose();<br/>dataStream = </span><span style="font-size:x-small;color:#0000ff">null</span><span style="font-size:x-small">;<br/>then to open a window form with many textbox combox and numeriupdown controls, as last, it report<br/> <p>See the end of this message for details on invoking <br/>just-in-time (JIT) debugging instead of this dialog box.</p> <p>************** Exception Text **************<br/>System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.<br/>   at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)<br/>   at System.Windows.Forms.NativeWindow.DefWndProc(Message&amp; m)<br/>   at System.Windows.Forms.Control.DefWndProc(Message&amp; m)<br/>   at System.Windows.Forms.Control.WndProc(Message&amp; m)<br/>   at System.Windows.Forms.TextBoxBase.WndProc(Message&amp; m)<br/>   at System.Windows.Forms.TextBox.WndProc(Message&amp; m)<br/>   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&amp; m)<br/>   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&amp; m)<br/>   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)</p> <p>i make sure that Clipboard operation and MemoryStream lead to corrupt memory, but why?</p> </span></p>Wed, 25 Nov 2009 15:31:37 Z2009-11-25T15:31:38Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/c8ad0326-0f69-48da-bc18-886a8e8d4e09http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/c8ad0326-0f69-48da-bc18-886a8e8d4e09Michał Januszczykhttp://social.msdn.microsoft.com/Profile/en-US/?user=Micha%u0142%20Januszczyk"Open with" file context menuIn my application I am trying to implement &quot;open with&quot; context menu. <br/>How can I read (probably from registry) registered applications paths that are registered to open <strong>specified extension</strong> ? (the list of applications that are displayed on the context menu (under &quot;Open with&quot; submenu) when user right clicks a file in windows explorer)<br/><br/>Thanks for help, <br/>MichalTue, 24 Nov 2009 15:43:26 Z2009-11-25T15:21:31Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/151d5c54-0aef-47ba-8885-2514f9b0e837http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/151d5c54-0aef-47ba-8885-2514f9b0e837Praveen K Nairhttp://social.msdn.microsoft.com/Profile/en-US/?user=Praveen%20K%20NairC# DLL Setup Project: How to create setup for a DLL to appear in "Add Reference"?<p class=MsoNormal style="margin:0in 0in 0pt"><span style="color:black"><span style="font-size:small"><span style="font-family:Calibri">Hi All,</span></span></span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="color:black"><span style="font-size:small;font-family:Calibri"> </span></span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="color:black"><span style="font-size:small"><span style="font-family:Calibri">I have created a setup project for a C# Class Library project (DLL) and added primary project output to “Global Assembly Cache Folder”.  I have also created a strong key for the assembly project as well before creating setup.  I could see the DLL in GAC (C:\SYSROOT\assembly) , but, it is not coming in “Add Reference” option.</span></span></span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="color:black"><span style="font-size:small;font-family:Calibri"> </span></span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="color:black"><span style="font-size:small"><span style="font-family:Calibri">It would be great if anyone could provide any pointer for this.  Thanks in advance.</span></span></span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="color:black"><span style="font-size:small;font-family:Calibri"> </span></span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="color:black"><span style="font-size:small"><span style="font-family:Calibri">Regards,</span></span></span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><strong><span style="color:black"><span style="font-size:small"><span style="font-family:Calibri">Praveen</span></span></span></strong></p>Wed, 25 Nov 2009 14:22:57 Z2009-11-25T14:57:33Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/33cc0e27-dbbf-499a-b507-761eafad1552http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/33cc0e27-dbbf-499a-b507-761eafad1552sush_raihttp://social.msdn.microsoft.com/Profile/en-US/?user=sush_raiMarshal.PtrToStructure throws System.Execution ExceptionI have a function that Converts Byte Array to Structure, where I am using Marshal.PtrToStructure.<br/> Marshal.PtrToStructure throws System.Execution Exception some time, I dont get this Exception all the time.<br/>When I perform Continous operation on a function which calls Marshal.PtrToStructure, during that time this Exception is thrown.<br/>Please let me know, how to resolve this.<br/>Wed, 25 Nov 2009 08:23:58 Z2009-11-25T14:21:29Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/6c79174b-f49f-4e3e-88b7-7c8d42731cf1http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/6c79174b-f49f-4e3e-88b7-7c8d42731cf1CalinMachttp://social.msdn.microsoft.com/Profile/en-US/?user=CalinMacManage Users Logged in my ApplicationHi there: <br/><br/>I hope this is the right forum for this question, if you believe another would be better suited I apologize in advance, please let me know.  <br/><br/>I know this has probably been asked before, but I am trying to find the most appropriate answer and I can't.  I have a Windows Forms application created using Visual Studio 2005, C# and Microsoft SQL Server 2005/2008.  It can be run on a network.  Some portions of the the application (mostly application setup routines) require to know either the number of users or if any users on the network are logged in the same SQL database or they are running my application at a certain time.  My application pools connections, so counting the numbers of connections to the same SQL database is not a good enough check.  Is there anything I can do to achieve this?  I was thinking something along the lines of a service, like a client-server application.  When a user starts the application it checks to see if a server is runing.  If it isn't, it starts the server, which then waits for clients.  If the server is already started it starts a client that can communicate with it.  Last client that stops the application also closes the server.  So basically at any time the server knows the number of users and maybe even more (local machine name, user ID, custom user priorities, etc).  <br/><br/>Any idea?  <br/><br/>Thanks, <br/> <hr class=sig> Calin, TorontoTue, 24 Nov 2009 20:53:19 Z2009-11-25T14:05:03Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/ae595bca-0af5-450b-bffc-47977e84c24ahttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/ae595bca-0af5-450b-bffc-47977e84c24aGodeffroyhttp://social.msdn.microsoft.com/Profile/en-US/?user=GodeffroyIn a TreeView how can we get the node newly ticked ?Hi,<br/> <br/> I would like to get the newly ticked Node.<br/> Treeview.Selected does not return the newly Node selected.<br/> <br/> Basically after the event After_Check i want to be able to quickly get the node selected.<br/> <br/> How can I do that ?Wed, 25 Nov 2009 11:44:19 Z2009-11-25T13:54:19Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/575cd8de-c174-4418-b9c8-45c86eb446c7http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/575cd8de-c174-4418-b9c8-45c86eb446c7sush_raihttp://social.msdn.microsoft.com/Profile/en-US/?user=sush_raiMarshal.PtrToStructure throws System.Execution ExceptionI have a function to Convert Byte Array to Structure, where I am using Marshal.PtrToStructure.<br/>Some times it throws System.Execution Exception not all the time.<br/> if  I Continously perform some operation, which calls ByteArrayToStructure function only then this Exception is thrown.<br/>Please Let me know, how to resolve this issue.<br/>Wed, 25 Nov 2009 08:14:45 Z2009-11-25T13:49:44Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/12ed56f0-030d-4a0f-852b-6486fc40f39bhttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/12ed56f0-030d-4a0f-852b-6486fc40f39bbeetlejuice78http://social.msdn.microsoft.com/Profile/en-US/?user=beetlejuice78Office 2007 and 2003 on Dev. PcI have both Office version on my Pc. It works correctly. But if I create a project (WPF Project) and add two referencess related with Office 12 version. These are : Microsoft.Office.Interop.Excel and Office and run it comes Excel 2003 window.<br/><br/>My Code is very simple, I create and application object then make it visible:<br/><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"> <p>Public</p> </span></span></span><span style="color:#0000ff;font-size:x-small"> <p> </p> </span></span> <p><span style="color:#2b91af;font-size:x-small"><span style="color:#2b91af;font-size:x-small">Application</span></span><span style="font-size:x-small"> myExcelApp;</span></p> <span style="font-size:x-small"><span style="font-size:x-small"> <p>myExcelApp =</p> </span></span> <p><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">new</span></span><span style="font-size:x-small"> </span><span style="color:#2b91af;font-size:x-small"><span style="color:#2b91af;font-size:x-small">Application</span></span><span style="font-size:x-small">();<span style="font-size:x-small"> <p>myExcelApp.Visible =</p> </span></span> <p> </p> <p><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">true;<br/><br/><span style="color:#000000">Please Help. Because I want to see after this code Excel 2007 window. What can I do?</span></span></span></p> </p>Thu, 12 Nov 2009 17:11:15 Z2009-11-25T11:49:19Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/4018d6e5-49b6-497f-9364-70f6b8fa0ea1http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/4018d6e5-49b6-497f-9364-70f6b8fa0ea1Craig Dahlingerhttp://social.msdn.microsoft.com/Profile/en-US/?user=Craig%20DahlingerGetting 'Unable to create mutex' exception using IsolatedStorage<span style="font-size:7.5pt;font-family:'Microsoft Sans Serif','sans-serif'"> <div>Getting the following exception when trying to use IsolatedStorage on a windows 7 machine.  This same code works fine on Windows XP or Vista.  Any insight would be most helpful.</div> <div>Thanks</div> <div><br/>CD</div> <div><br/></div> <div>Sample method:</div> <div><br/></div> <div> <div>public static IsolatedStorageFileStream GetIsolatedStorageFileStream(string fileName,FileMode fileMode)</div> <div>        {</div> <div>            </div> <div><br/></div> <div>            IsolatedStorageFile isolatedStorageFile = IsolatedStorageFile.GetUserStoreForAssembly();</div> <div>            </div> <div>            IsolatedStorageFileStream fileStream;</div> <div><br/></div> <div>            string existingFile = FindExistingStorageFile(isolatedStorageFile, fileName);</div> <div><br/></div> <div>            if(!(String.IsNullOrEmpty(existingFile)))</div> <div>            {</div> <div>                fileStream = new IsolatedStorageFileStream(fileName, fileMode, isolatedStorageFile);</div> <div>            }</div> <div>            else</div> <div>            {</div> <div>                fileStream = new IsolatedStorageFileStream(fileName, FileMode.Create, isolatedStorageFile);</div> <div>            }</div> <div><br/></div> <div>            return fileStream;</div> <div>            </div> <div>        }</div> </div> <div><br/></div> <div><br/></div> <div>when trying to access the returned stream, I am receiving the following exception.</div> <div><br/></div> Top Exception<br/> Type=System.IO.IsolatedStorage.IsolatedStorageException<br/> Source=mscorlib<br/> Message=Unable to create mutex. (Exception from HRESULT: 0x80131464)<br/> StackTrace:<br/> at System.IO.IsolatedStorage.IsolatedStorageFile.nOpen(String infoFile, String syncName)<br/> at System.IO.IsolatedStorage.IsolatedStorageFile.Lock()<br/> at System.IO.IsolatedStorage.IsolatedStorageFileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, IsolatedStorageFile isf)<br/> at System.IO.IsolatedStorage.IsolatedStorageFileStream..ctor(String path, FileMode mode, IsolatedStorageFile isf)</span><hr class="sig">Craig Dahlinger - Software DeveloperTue, 24 Nov 2009 21:13:45 Z2009-11-25T11:06:02Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/263a6977-b05d-429b-8b06-a8f35a78a58dhttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/263a6977-b05d-429b-8b06-a8f35a78a58dAnillalillyhttp://social.msdn.microsoft.com/Profile/en-US/?user=AnillalillyPreventing removel of Images from ImageList at runtimeIf an imagelist contains some images and it is binded to propertygrid. How we can prevent removel of Images from ImageList at runtime through propery grid? That means making the imaglist ReadOnly..Thu, 19 Nov 2009 09:53:35 Z2009-11-25T11:00:11Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/876f2cad-d5e2-44ba-bd1f-3d9c35032d7chttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/876f2cad-d5e2-44ba-bd1f-3d9c35032d7cNaga Harishhttp://social.msdn.microsoft.com/Profile/en-US/?user=Naga%20HarishXmlserialization for PropertyBag (For Property tag)Hi to all,<br/> I got sample code for <strong>PropertyBag</strong> . It is real nice one. It works good.  Source code is here<br/> <a title=Codeproject href="http://www.codeproject.com/KB/recipes/propertybag.aspx" title=Codeproject>http://www.codeproject.com/KB/recipes/propertybag.aspx</a> .(Please download and check)<br/> <br/> But my problem is to generate xml file (XMLserialization). If I tried with XML serialization it is not craete tags for PropertyBag. But if we use Soap serialization it is creating.<br/> I use this <strong>Code</strong> for XML serialization :-<br/> using System.Xml.Serialization;<br/>             XmlSerializer s = new XmlSerializer(typeof(Address));<br/>             TextWriter w = new StreamWriter(&quot;MyClass.xml&quot;);<br/>             s.Serialize(w, objAddress);<br/>             w.Close();<br/> <br/> <strong>Output XMl file: MyClass.xml</strong> <br/> &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;<br/> &lt;Address xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot;&gt;<br/>   &lt;Line1&gt;22 North Street&lt;/Line1&gt;<br/>   &lt;Line2&gt;Northby&lt;/Line2&gt;<br/>   &lt;Line3 /&gt;<br/>   &lt;City&gt;Northtown&lt;/City&gt;<br/>   &lt;County&gt;Northshire&lt;/County&gt;<br/>   &lt;Country&gt;Northaria&lt;/Country&gt;<br/>   &lt;PostCode&gt;NN1 1NN&lt;/PostCode&gt;<br/> &lt;/Address&gt;<br/> <br/> Thanks,<br/> :)Wed, 11 Nov 2009 08:34:22 Z2009-11-25T10:40:54Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/31d5eeed-83ca-4bb9-b59f-49381151a1aehttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/31d5eeed-83ca-4bb9-b59f-49381151a1aetaironhttp://social.msdn.microsoft.com/Profile/en-US/?user=taironHow do I detect whether touchscreen or mouse?Hi, I hope this is the right forum for this question.<br/><br/>Is there anyway to detect if the user is using touchscreen or mouse on XP/Vista/Windows 7?<br/><br/>I found the StylusAsyncPlugin examples which is supposed to work with xp tablet or vista+. but the App is not using forms and I can't find a way to make it work without it.<br/><br/>I'm using the XNA framework and .net 3.5 no Forms or xaml.<br/><br/>/Christoffer<br/>Thu, 05 Nov 2009 17:16:21 Z2009-11-25T10:20:59Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/79e4dec1-1119-4612-805f-c1aeee0fdc3ehttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/79e4dec1-1119-4612-805f-c1aeee0fdc3eMini2http://social.msdn.microsoft.com/Profile/en-US/?user=Mini2Registry and Windows 7Hello, <br/> <br/> I have an existing # (.net 2.0) applicatione which works fine on XP and Vista machines but not on all Windows 7 machines (it works on a 32bit Business version and on a 32bit Starter version (on a netbook), but it does not work on a 64bit home premium version).<br/> <br/> The code is quite easy:<br/> <pre lang="x-c#">RegistryKey regkey = Registry.LocalMachine.CreateSubKey(&quot;SOFTWARE\\MYCOMPANY&quot;); </pre> But an exception is thrown at this line.<br/> <br/> After this I check read some values (with a default value so they are created if they don't exist).<br/> The registry key is not created at installation (but this does not seem to be a problem with the other machines) and when I manually create the key the problem remains the same.<br/> Although I'm logged in as a user with administrator rights, the problem occurs when I start the executable by double clicking it, but is does not occur when I right click the exe and choose &quot;Run as administrator&quot; (the key and its values are created in the normal registry not in the Wow6432Node, see below)<br/> <br/> I'm not sure the problem is &quot;Windows 7&quot; or &quot;64bit&quot; related.<br/> I've read some things about 32bit applications accessing the 64 bit registry but I'm not sure if I fully understand it. Can anyone tell me if this is correct:<br/> - For 32 bit application there is a special key inside the 64bit registry (\HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node)<br/> - this node is a kind of &quot;virtual&quot; 32 bit registry where 32bit applications can write to<br/> - My code above should automatically write to this special node when working on a 64 bit machine (and to the normal registry on 32 bit systems). <br/> <br/> If the above is correct, I think I can conclude that the problem is &quot;Windows 7&quot; related<br/> <br/> With Vista I had a similar problem in the past but this was because I used OpenSubkey(&quot;SOFTWARE&quot;). This I can understand because opening the &quot;SOFTWARE&quot; key is a bit suspicious.<br/> <br/> Anybody a suggestion (besides a return to an &quot;ini&quot; file)?Wed, 25 Nov 2009 09:39:21 Z2009-11-25T09:39:21Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/863297be-23b0-48ca-bab4-a9079d772075http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/863297be-23b0-48ca-bab4-a9079d772075Naren7http://social.msdn.microsoft.com/Profile/en-US/?user=Naren7usercontrol in windows<p>hello mr david<br/><br/> want to know  how to create user control for mulitple tabpage with web browser control in windows form using c#.net for html editors .</p><hr class="sig">NarenWed, 25 Nov 2009 09:25:17 Z2009-11-25T09:25:18Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/f9e39595-04ca-42ae-a353-eb1a08602631http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/f9e39595-04ca-42ae-a353-eb1a08602631den2005http://social.msdn.microsoft.com/Profile/en-US/?user=den2005[RESOLVED] Creating Image File: Parameter is not valid.<p>Hi everybody,</p> <p>   I am creating an image(jpeg) file from stored bytes[] in sql database, Varbinary datatype, (I used Image datatype also same result), I am using this jpeg image file to set to a Image web control, what seems the problem and how to fix this problem?  Do I have proper datatype in sql to store converted jpeg file data? Please provide codes. Thanks.</p> <p>[code]<br>string sqlText = "Select * From PictureImages Where ImageName = @ImgName";<br>SqlCommand cmd = new SqlCommand(sqlText, conn);<br>cmd.Parameters.Add("@ImgName", SqlDbType.VarChar, 20, "ImageName").Value = txtImgName.Text.Trim();</p> <p>if (conn.State == ConnectionState.Closed)<br>   conn.Open();</p> <p>SqlDataReader dr = cmd.ExecuteReader();<br>string filePath = Request.PhysicalApplicationPath + txtImgName.Text + ".jpg";<br>FileStream fs = new FileStream(filePath, FileMode.Create, FileAccess.Write);</p> <p>byte[] storedByte = null;</p> <p>while (dr.Read())<br>{<br>   lblImgNo.Text = dr["ImageNo"].ToString();<br>   txtImgDesc.Text = dr["Description"].ToString();<br>   txtImgUrl.Text = dr["ImageUrl"].ToString();<br>   storedByte = (byte[])dr["ImageData"];<br>}</p> <p>MemoryStream ms = new MemoryStream(storedByte);<br>Bitmap img = (Bitmap)System.Drawing.Image.FromStream(ms); <strong>&lt;&lt;-- Error Occurred Here</strong></p> <p>img.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);<br>ms.Close();<br>img.Dispose();</p> <p>[/code]</p> <p>Nobody seems to know how to solve this???</p> <p> </p> <p>den2005<img src="images/emoticons/smile_regular.gif"></p> <p> </p> <p> </p>Mon, 07 Aug 2006 08:09:29 Z2009-11-25T09:19:16Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/98d8f2b9-77a3-483e-aa64-bd9b0ab544c2http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/98d8f2b9-77a3-483e-aa64-bd9b0ab544c2Naren7http://social.msdn.microsoft.com/Profile/en-US/?user=Naren7problem in creating user control for mutilple tabpageshello<br/><br/>I want to know  how to create user control for mulitple tabpage with web browser control in windows form using c#.net for html editors .<hr class="sig">NarenWed, 25 Nov 2009 09:10:24 Z2009-11-25T09:10:25Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/d1eb70d8-ef39-4d7a-b6c9-053eb69c4dc4http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/d1eb70d8-ef39-4d7a-b6c9-053eb69c4dc4ozone5http://social.msdn.microsoft.com/Profile/en-US/?user=ozone5MD5 Descryption exception on a string length > 7 charsHi,<br/> <br/> I'm trying to decrypt a string with MD5 method. My method  string Md5Encrypt(string Message) seems to work only when Message length is under 8 chars. Over 7 chars the method throws the following exception :<br/> <br/> <span style="text-decoration:underline"><strong>Error message </strong> </span> <br/> Length of the data to decrypt is invalid.<br/> <br/> <span style="text-decoration:underline"><strong>StackTrace : </strong> </span>    <br/> at System.Security.Cryptography.CryptoAPITransform.TransformFinalBlock(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount)<br/> at Gpeto.Functions.Md5Decrypt(String <br/> <br/> This is my method (I took it from the following website  : http://www.dijksterhuis.org/encrypting-decrypting-string/ )<br/> <div style="color:Black;background-color:White"> <pre><span style="color:Blue">public</span> <span style="color:Blue">static</span> <span style="color:Blue">string</span> Md5Decrypt(<span style="color:Blue">string</span> Message) { <span style="color:Blue">try</span> { <span style="color:Blue">if</span> (Message == <span style="color:Blue">null</span> ) <span style="color:Blue">return</span> <span style="color:Blue">null</span> ; <span style="color:Blue">string</span> Passphrase = <span style="color:#a31515">&quot;KeyWord&quot;</span> ; <span style="color:Blue">byte</span> [] Results; System.Text.UTF8Encoding UTF8 = <span style="color:Blue">new</span> System.Text.UTF8Encoding(); <span style="color:Green">// Step 1. We hash the passphrase using MD5</span> <span style="color:Green">// We use the MD5 hash generator as the result is a 128 bit byte array</span> <span style="color:Green">// which is a valid length for the TripleDES encoder we use below</span> MD5CryptoServiceProvider HashProvider = <span style="color:Blue">new</span> MD5CryptoServiceProvider(); <span style="color:Blue">byte</span> [] TDESKey = HashProvider.ComputeHash(UTF8.GetBytes(Passphrase)); <span style="color:Green">// Step 2. Create a new TripleDESCryptoServiceProvider object</span> TripleDESCryptoServiceProvider TDESAlgorithm = <span style="color:Blue">new</span> TripleDESCryptoServiceProvider(); <span style="color:Green">// Step 3. Setup the decoder</span> TDESAlgorithm.Key = TDESKey; TDESAlgorithm.Mode = CipherMode.ECB; TDESAlgorithm.Padding = PaddingMode.PKCS7; <span style="color:Green">// Step 4. Convert the input string to a byte[]</span> <span style="color:Blue">byte</span> [] DataToDecrypt = Convert.FromBase64String(Message.Replace(<span style="color:#a31515">' '</span> ,<span style="color:#a31515">'+'</span> )); <span style="color:Green">// Step 5. Attempt to decrypt the string</span> <span style="color:Blue">try</span> { ICryptoTransform Decryptor = TDESAlgorithm.CreateDecryptor(); Results = Decryptor.TransformFinalBlock(DataToDecrypt, 0, DataToDecrypt.Length); } <span style="color:Blue">finally</span> { <span style="color:Green">// Clear the TripleDes and Hashprovider services of any sensitive information</span> TDESAlgorithm.Clear(); HashProvider.Clear(); } <span style="color:Green">// Step 6. Return the decrypted string in UTF8 format</span> <span style="color:Blue">return</span> UTF8.GetString(Results); } <span style="color:Blue">catch</span> (Exception v_oEx) { <span style="color:Blue">throw</span> <span style="color:Blue">new</span> Exception(<span style="color:#a31515">&quot;Unable to decrypt the word&quot;</span> ); } } </pre> </div> <br/> <br/>Tue, 24 Nov 2009 10:11:21 Z2009-11-25T07:54:43Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/25281372-3b7a-4313-ba04-30f77fd9bb62http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/25281372-3b7a-4313-ba04-30f77fd9bb62Andro Fonthttp://social.msdn.microsoft.com/Profile/en-US/?user=Andro%20FontProblem passing arguments to Process.Start()Hi!<br/> I have an application that recieve, as command arguments, filepaths as string and it most load that files then I have other application and the second app use the methods Process.Star() to run the first and pass it the filepaths.When I pass 8 files everithing works fine, but with more the methods throw a Win32Exception(Access Denied).<br/> <br/> Here is my code<br/> <br/> <div style="color:Black;background-color:White"> <pre><span style="color:Blue">class</span> Program { <span style="color:Blue">static</span> <span style="color:Blue">void</span> Main() { <br/> DirectoryInfo directory = <span style="color:Blue">new</span> DirectoryInfo(<span style="color:#a31515">&quot;Folder with files&quot;</span> ); List&lt;FileInfo&gt; files = GetFiles(directory); Process.Start(<span style="color:#a31515">&quot;MyAppLocation&quot;</span> , CreateArguments(files)); } <span style="color:Blue">private</span> <span style="color:Blue">static</span> List&lt;FileInfo&gt; GetFiles(DirectoryInfo directory) { List&lt;FileInfo&gt; files = <span style="color:Blue">new</span> List&lt;FileInfo&gt;(); DirectoryInfo[] directories = directory.GetDirectories(); <span style="color:Blue">for</span> (<span style="color:Blue">int</span> i = 0; i &lt; directories.Length; i++) { files.AddRange(GetFiles(directories[i])); } files.AddRange(directory.GetFiles(<span style="color:#a31515">&quot;*.xxx&quot;</span> )); <span style="color:Blue">return</span> files; } <span style="color:Blue">private</span> <span style="color:Blue">static</span> <span style="color:Blue">string</span> CreateArguments(List&lt;FileInfo&gt; files) { StringBuilder arguments = <span style="color:Blue">new</span> StringBuilder(<span style="color:#a31515">&quot; &quot;</span> ); <span style="color:Blue">foreach</span> (<span style="color:Blue">var</span> file <span style="color:Blue">in</span> files) arguments.Append(<span style="color:#a31515">&quot;\&quot;&quot;</span> + file.FullName + <span style="color:#a31515">&quot;\&quot; &quot;</span> ); <span style="color:Blue">return</span> arguments.ToString(); } } </pre> </div>Wed, 25 Nov 2009 06:09:20 Z2009-11-25T07:02:58Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/407925f0-383a-4901-9b16-5da2b771b946http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/407925f0-383a-4901-9b16-5da2b771b946Jungbahadurhttp://social.msdn.microsoft.com/Profile/en-US/?user=JungbahadurExcel document in ASP.Net 3.5<p>Hi All,<br/><br/>My requirement is kind of export to excel funtionality from a search page, where the number of columns and rows will be decided on the creteria selected by user. But the basic design of the excel is fixed..... so I was thinking if it is possible to have ready template in XML/XSD/XSLT/EXCEL or something where all the formatting thing can be predefined and at runtime somehow to repeat the rows and coulmn with their respective cell values (If possible would like to add formulas also).<br/><br/>The data has to be pulled from the database so there is no luxury for me to generate excel direcly from DataGrid. Since the excel will be dynamically generated, immediate reponse is expected.<br/><br/>I am completely new to XML and Excel thing and looking for a sample / article for acehive this in the best way. <br/><br/>Looking for your valuable suggestions...<br/><br/>With Best Regards,</p>Wed, 25 Nov 2009 06:07:19 Z2009-11-25T06:40:59Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/ec2b919d-1113-4fc3-82db-124542f86ddfhttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/ec2b919d-1113-4fc3-82db-124542f86ddfMurali123http://social.msdn.microsoft.com/Profile/en-US/?user=Murali123How to find out VPN Logon User NameHi,<br/>  I need to figure how do I find out currently logged in domain user (not the user who logged in to the machine or local user). Lets say user logs in to the local machine using local work group user name and pwd. And then he RAS in to the corporate network using smart card or similar. How can we find out the logged in user as opposed to the user who logged in to local machine. I tried all existing win32APIs as well as sytem.security etc .. all of them are returning user logged in to local machine. I need to find out VPN domain user. Let me know if anyone has solution to this.<br/><br/>Regards,<br/>MuraliTue, 24 Nov 2009 19:09:38 Z2009-11-25T05:56:05Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/25081d2c-b129-44ca-9f3b-dfda0a4293eehttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/25081d2c-b129-44ca-9f3b-dfda0a4293eeRyan Mathewhttp://social.msdn.microsoft.com/Profile/en-US/?user=Ryan%20MathewUnable to invoke event in WorkflowI have a state machine workflow and i m trying to invoke an event. From my UI I am calling a method which will invoke an event. <br/><br/><span style="font-size:x-small;color:#0000ff"><span style="font-size:x-small;color:#0000ff"><font size=2 color="#0000ff"><font size=2 color="#0000ff"> <p>namespace</p> </font></font></span><font size=2 color="#0000ff"> <p> </p> </font></span> <p><span style="font-size:x-small"> StateMachineWorkflowDemo <p>{</p> <font size=2> <p> </p> </font></span></p> <p><span style="font-size:x-small;color:#0000ff"><span style="font-size:x-small;color:#0000ff">public</span></span><span style="font-size:x-small"> </span><span style="font-size:x-small;color:#0000ff"><span style="font-size:x-small;color:#0000ff">class</span></span><span style="font-size:x-small"> </span><span style="font-size:x-small;color:#2b91af"><span style="font-size:x-small;color:#2b91af">ManageApproval</span></span><span style="font-size:x-small"> : </span><span style="font-size:x-small;color:#2b91af"><span style="font-size:x-small;color:#2b91af">IApproval</span></span></p> <span style="font-size:x-small"> <p>{</p> <font size=2> <p> </p> </font></span> <p><span style="font-size:x-small;color:#0000ff"><span style="font-size:x-small;color:#0000ff">public</span></span><span style="font-size:x-small"> </span><span style="font-size:x-small;color:#0000ff"><span style="font-size:x-small;color:#0000ff">event</span></span><span style="font-size:x-small"> </span><span style="font-size:x-small;color:#2b91af"><span style="font-size:x-small;color:#2b91af">EventHandler</span></span><span style="font-size:x-small"> &lt;</span><span style="font-size:x-small;color:#2b91af"><span style="font-size:x-small;color:#2b91af">ApprovalEventArgs</span></span><span style="font-size:x-small">&gt; ApprovalPayment;<font size=2> <p> </p> </font></span></p> <p><span style="font-size:x-small;color:#0000ff"><span style="font-size:x-small;color:#0000ff">public</span></span><span style="font-size:x-small"> </span><span style="font-size:x-small;color:#0000ff"><span style="font-size:x-small;color:#0000ff">void</span></span><span style="font-size:x-small"> ApproveExpenseReport(</span><span style="font-size:x-small;color:#2b91af"><span style="font-size:x-small;color:#2b91af">Guid</span></span><span style="font-size:x-small"> expenseReportId, </span><span style="font-size:x-small;color:#2b91af"><span style="font-size:x-small;color:#2b91af">Boolean</span></span><span style="font-size:x-small"> isApproved, </span><span style="font-size:x-small;color:#2b91af"><span style="font-size:x-small;color:#2b91af">Guid</span></span><span style="font-size:x-small"> wfInstanceId) <p>{</p> <font size=2> <p> </p> </font></span></p> <p><span style="font-size:x-small;color:#2b91af"><span style="font-size:x-small;color:#2b91af">ApprovalEventArgs</span></span><span style="font-size:x-small"> appArgs = </span><span style="font-size:x-small;color:#0000ff"><span style="font-size:x-small;color:#0000ff">new</span></span><span style="font-size:x-small"> </span><span style="font-size:x-small;color:#2b91af"><span style="font-size:x-small;color:#2b91af">ApprovalEventArgs</span></span><span style="font-size:x-small">(wfInstanceId); <p>appArgs.IsApproved = isApproved;</p> <font size=2> <p> </p> </font></span></p> <p><span style="font-size:x-small;color:#0000ff"><span style="font-size:x-small;color:#0000ff">if</span></span><span style="font-size:x-small"> (ApprovalPayment != </span><span style="font-size:x-small;color:#0000ff"><span style="font-size:x-small;color:#0000ff">null</span></span><span style="font-size:x-small">) <p>{</p> <font size=2> <p>ApprovalPayment(</p> </font></span></p> <p><span style="font-size:x-small;color:#0000ff"><span style="font-size:x-small;color:#0000ff">this</span></span><span style="font-size:x-small">, appArgs); <p>}</p> <p>}</p> <p>}</p> <p>}<br/><br/>But for me ApprovalPayment is always coming as null and it's not getting ivoked. Can someone help me in this?</p> </span></p>Wed, 25 Nov 2009 05:49:12 Z2009-11-25T05:49:12Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/0fc2fd76-03a6-4efc-b6a8-7a484edfc834http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/0fc2fd76-03a6-4efc-b6a8-7a484edfc834ananda vardhanahttp://social.msdn.microsoft.com/Profile/en-US/?user=ananda%20vardhanaBIG Integer Library suggestion <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:8pt;color:black;font-family:Verdana">Folks,<br/><br/>I want to do  &gt; 100 integers +, -, x, and / basic operations and square root. There are many BIG Integer libraries freely available some go with C++ and mostly with Linux and other OS's. I am not confident enough to use them ... Last year I wasted lot of time on them and finally gave up beset with bugs. Does Microsoft provide any such library? Or Wolfram? I want a library which will seamlessly get included in the VS2005 build environment and work with C#. I dont mind buying it if I am going to get a quality product. Please advice. <br/><br/>thanks<br/>ananda</span></p>Tue, 24 Nov 2009 20:16:50 Z2009-11-25T05:32:56Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/18ef59de-88c4-46ce-8c75-44f922b00b6chttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/18ef59de-88c4-46ce-8c75-44f922b00b6cneilkonitzerhttp://social.msdn.microsoft.com/Profile/en-US/?user=neilkonitzerAVICAP32.DLL Suppress "Select a Video Device" Dialog BoxI have a WinForms application that uses AVICAP32.DLL to preview a webcam video and take snap shots. Everything works fine on my development machine; however, when deployed to another machine and connect to the webcam using AVICAP, I receive numerous (2 or 3) &quot;Select a Video Device&quot; dialog boxes. Is there a way that I can prevent these from appearing? The machine where this is being deployed only has one video device, a built-in web cam. The built-in device is the only item shown in the list. Here is my code:<br/> <pre lang="x-c#">hWnd = capCreateCaptureWindowA(&quot;0&quot;, WS_VISIBLE | WS_CHILD, 0, 0, 0, 0, pbCtrl.Handle.ToInt32(), 0); if (SendMessage(hWnd, WM_CAP_DRIVER_CONNECT, 0, 0) != 0) { SendMessage(hWnd, WM_CAP_SET_SCALE, 1, 0); SendMessage(hWnd, WM_CAP_SET_PREVIEWRATE, 30, 0); SendMessage(hWnd, WM_CAP_SET_PREVIEW, 1, 0); SetWindowPos(hWnd, HWND_BOTTOM, 0, 0, pbCtrl.Width, pbCtrl.Height, SWP_NOMOVE | SWP_NOZORDER); }</pre> <br/> Thanks in advance!Tue, 24 Nov 2009 21:07:13 Z2009-11-25T03:40:47Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/3e3934fa-5eff-4580-9977-6282958f2cadhttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/3e3934fa-5eff-4580-9977-6282958f2cadvijmenhttp://social.msdn.microsoft.com/Profile/en-US/?user=vijmenBest Practice : call ActiveX control from C#Hi <div><span style="background-color:#ffffff"><br/></span> <div>I am new to c# and .NET programming. However, it has been an interesting and fascinating experience so far.</div> <div><br/></div> <div>My problem is that I have an ocx file which I want to call using a c# program. </div> <div><br/></div> <div>Are there any approaches or tutorials that are available for this scenario? </div> <div><br/></div> <div>Thanks in advance for your help.</div> <div><br/></div> <div>Regards</div> <div><br/></div> <div>vm</div> <div><br/></div> <div><br/></div> </div>Wed, 25 Nov 2009 02:34:44 Z2009-11-25T03:25:12Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/227c089f-1254-4cd2-b14a-0716495d29f8http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/227c089f-1254-4cd2-b14a-0716495d29f8st1ledhttp://social.msdn.microsoft.com/Profile/en-US/?user=st1ledMaking a List<T> a "kind of referenced subset" of another List<T>Hi everybody! I know the title could be a little confusing, but I really couldn't find a better one. I'm sure a little example will be useful to understand what I want to achieve. Let's suppose I have two List&lt;int&gt; (mainList and derivedList) as shown below. I'd like to find a way to initialize derivedList to achieve the following behavior:<br/> <br/> <br/> <pre lang="x-c#"> List&lt;int&gt; mainList = new List&lt;int&gt;(); mainList.Add(1); mainList.Add(2); mainList.Add(3); //mainList now has numbers 1,2,3 List&lt;int&gt; derivedList = new List&lt;int&gt;(); //Init derivedList to have the same objects as mainList: derivedList should now have numbers 1,2,3 //1. removing an element from the base list should remove it from both mainList.Remove(2); //mainList should now have numbers 1,3 //derivedList should now have numbers 1,3,100 //2. adding an element from the base list should add it to both mainList.Add(50); //mainList should now have numbers 1,3,50 //derivedList should now have numbers 1,3,50,100 //3. adding an element from the derived list should add it only to the derived list derivedList.Add(100); //derivedList should now have numbers 1,2,3,100 //mainList should now have numbers 1,2,3 //4. removing an element which is in the derived list, should remove it from both if it is a referenced element of the vase list... derivedList.Remove(1); //derivedList should now have numbers 2,3,100 //mainList should now have numbers 2,3 //5. or remove it just from the derived list if it is a proper derivedList element derivedList.Remove(100); //derivedList should now have numbers 2,3 //mainList should now have numbers 2,3</pre> <br/> <br/> Is it possible to have such a &quot;referenced superset-subset&quot; behavior? The two List&lt;T&gt; objects could also be a List&lt;A&gt; and List&lt;B&gt; where B (the type of the derivedList) inherits from A (the type of the baseList).<br/> <br/> Is may be clear to you all, that neither initializing the derivedList copying the baseList objects works (fails at steps 1-2-4-5) nor making the derivedList a reference of the baseList (fails at steps 3) work. At the moment I don't have any idea, besides writing a new class with Add and Remove methods to make (redundant?) checks to the two lists in order to keep them consistent, which sounds me way too pesky.<br/> <br/> What do you suggest to do in order to solve this problem? Since I'm not too sure that this can be done, or maybe it cannot be done with the List class, I'm open to any kind of solution; mind that if necessary I'll provide some context informations to make you all know the domain of my problem (what is my application and what I actually want to achieve, besides this toy-example).<br/> <br/> Thank you for your patience,<br/> Regards, Stefano<hr class="sig">there in the deepest well of dreams // echoed a distant song // I hearkened to the hallowed voice // stirred from ageless sleep // through this barren soil you came // sweet scent of spring // came and cast the earth in bloom // lent your light to me Sat, 21 Nov 2009 19:11:34 Z2009-11-24T23:14:45Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/7dda1961-c195-4a08-9d5d-1ffb554d665fhttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/7dda1961-c195-4a08-9d5d-1ffb554d665fO.Z.http://social.msdn.microsoft.com/Profile/en-US/?user=O.Z.How to specify default value (DefaultSettingValueAttribute) for ApplcationSettingsBase property in C++Hi, <br/><br/>  I'm developing some facade code for an ApplicationSettingsBase derived class to talk to native code. I've encountered that addressing Int32 property w/o previously setting it raises the following exception of type System::ArgumentException^.<br/><br/>ex = 0x02d09db0 { &quot;The property 'intProperty' could not be created from it's default value. Error message: System.ValueType is an unsupported type. Please use [XmlIgnore] attribute to exclude members of this type from serialization graph.&quot;}<br/><br/>  I really wonder what is the correct way to specify default value for Int32 property other then just a string representation of a valid integer number. Here are snippets that demonstrate the situation.<br/><br/>  Dummy settings class is defined as follows<span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">  <pre lang=x-cpp>ref struct Settings: public ApplicationSettingsBase { [UserScopedSettingAttribute()] [DefaultSettingValueAttribute(&quot;431&quot;)] property System::Int32^ intProperty { System::Int32^ get() { return static_cast&lt;System::Int32^&gt;(this[charPtr2Managed(intOptionName)]); } void set(System::Int32^ left) { try { this[charPtr2Managed(intOptionName)] = left; } catch (SettingsPropertyNotFoundException^ ) { throw; } } } }</pre> <font size=2 color="#0000ff"><font size=2 color="#0000ff"> <p> </p> </font></font></span><font size=2 color="#0000ff"> <p> </p> </font></span> <p>And here is code that generates exception</p> <pre lang=x-cpp>Settings^ settings = gcnew Settings; bool flag = settings-&gt;intProperty == value;</pre> <p>Thanks.<br/><br/> </p><hr class="sig">WBR O.Z.Tue, 24 Nov 2009 22:16:18 Z2009-11-24T22:16:19Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/f1a8c108-500f-420d-9acc-da626e2cd900http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/f1a8c108-500f-420d-9acc-da626e2cd900rsinehttp://social.msdn.microsoft.com/Profile/en-US/?user=rsinedynamic IF statements<p>I have a project that requires data from a csv file to be manipulated into a new csv file.  While some of the manipulation is simply straight mapping of data from the input csv to the output csv, the more complex part of the project is the dynamic IF statement requirement for some mappings.  For this, the project requires some mappings to execute a series of IF..THEN..ELSE statements but the kicker is the user should be in full control of these statements.  By full control, I mean each mapping should be visible to the user and he can add, subtract, or modify IF clauses per mapping.  Is this possible in .Net and if so, how would I go about doing it?  Examples are appreciated.</p> <p>-Thank you </p>Tue, 24 Nov 2009 16:22:44 Z2009-11-24T21:35:11Z