Dll not getting copied to bin directory in Visual Studio



In one of our projects we were referencing custom assemblies that were part of the same solution. However those assemblies were not getting copied to the bin directory of the project upon building the project.

We had also set property Copy Local as true for those class library projects.

The reason for this was as we were adding those assemblies in GAC.

VS.NET will copy the dll to the bin directory if your system cannot find the dll in the GAC.”

After removing those assemblies from GAC it added those dlls in the bin.

The helpful thread


Hope it helps..

Fixed – Cannot obtain value of local or argument as it not available at the instruction pointer, possibly because it has been optimized away while debugging in Visual Studio



Was facing this the above issue while trying to debug the code. The debugger was getting attached properly but it wasn’t showing values for the variables.
Unchecking the following option in the class library project properties fixed the issue



This helpful post.




How to Read the InfoPath content and extract the attachment using XMLDocument in C#


The InfoPath form:-

The namespace and the field1 that is node that contains the attachment

Sample Code:

XmlDocument myDoc = new XmlDocument();

// specify the name space
XmlNamespaceManager ns = new XmlNamespaceManager(myDoc.NameTable);
ns.AddNamespace("my", "http://schemas.microsoft.com/office/infopath/2003/myXSD/2014-07-12T15:29:09");

// the node that contains the attachment
XmlNodeList nl = myDoc.SelectNodes("/my:myFields/my:group1/my:group2/my:field1", ns);
foreach (XmlNode n in nl)
string s = n.InnerText;
byte[] b = Convert.FromBase64String(s);
int nameBufferLen = b[20] * 2;

// file name buffer to get the filename with extension
byte[] fileNameBufffer = new Byte[nameBufferLen];

for (int i = 0; i < nameBufferLen; i++)
fileNameBufffer[i] = b[24 + i];
char[] charFileName = UnicodeEncoding.Unicode.GetChars(fileNameBufffer);
string fileName = new string(charFileName);
fileName = fileName.Substring(0, fileName.Length - 1);

// byte array for the remaining content
byte[] fileContent = new byte[b.Length - (24 + nameBufferLen)];

for (int i = 0; i < fileContent.Length; i++)
fileContent[i] = b[24 + nameBufferLen + i];

FileStream fs = new FileStream(@"C:\test\" + fileName, FileMode.Create);
fs.Write(fileContent, 0, fileContent.Length);


Hope it helps..





HashSet with Custom Class in C#


Check out this wonderful post on understanding HashSet




The Message box will show the count as 2.

HashSet will remove the duplicate entry.