joi, 19 ianuarie 2012

Could not load file or assembly or one of its dependencies.

The full error text is in fact:

Could not load file or assembly 'xxx.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format
and may occur when using Visual Studio 2005 on 64-bit platforms. A common cause of this error is when using third party tools that require the license compiler (lc.exe). On 64 bit systems, the license compiler will run as a 64-bit application by default and if the third party libraries are not compatible with 64-bit platforms, the aforementioned error is generated. One solution to fix this, even though in this case you will be limited to compiling your whole application in x86 mode, is to add the following code in the pre-build and post-build event sections of the project's Build Events section. The statements must be on a single line.


if exist %WINDIR%\Microsoft.NET\Framework64\v2.0.50727\ %WINDIR%\Microsoft.NET\Framework64\v2.0.50727\ldr64.exe setwow
if exist %WINDIR%\Microsoft.NET\Framework64\v2.0.50727\ %WINDIR%\Microsoft.NET\Framework64\v2.0.50727\ldr64.exe set64
For more information on the license compiler, see this post on MSDN: I must say I have tried other solutions, as explained in other blogs or forums on-line, which advise to change the target platform to x86 or Any CPU, but those did not work for me.

marți, 3 ianuarie 2012

Show Control in Visual Studio 2005 Toolbox

After creating a custom control with Visual Studio 2005 you may want to have it available in the Toolbox to easily drag and drop it on your own forms. There is an option in Visual Studio 2005 that enables or disables the adding the of the custom control in the Toolbox. To make sure that your control will show up in the Toolbox, verify that under Tools->Options->Windows Forms Designer, the AutoToolboxPopulate option is set to true.

luni, 2 ianuarie 2012

The path is not of a legal form.

In Visual Studio 2005 I got this error when trying to open a form in design mode. This was not a programming error because I was able to properly compile and run my code. After looking at the projects in my solution (luckily, just two simple projects) I have found that one of the projects had a dead reference - a reference with an exclamation mark. I removed that reference and I am now again able to open my form in design mode. I believe a better formulation of the error message would be very helpful in this case.
I post the error stack below, for reference:

The path is not of a legal form.
at System.IO.Path.NormalizePathFast(String path, Boolean fullCheck)
at System.IO.Path.NormalizePath(String path, Boolean fullCheck)
at System.IO.Path.GetFullPathInternal(String path)
at System.Reflection.AssemblyName.GetAssemblyName(String assemblyFile)
Microsoft.VisualStudio.Design.VSTypeResolutionService.AddProjectDependencies(Project project)
Microsoft.VisualStudio.Design.VSTypeResolutionService.AssemblyEntry.Search(String fullName, String typeName, Boolean ignoreTypeCase, Assembly& assembly, String description) at
Microsoft.VisualStudio.Design.VSTypeResolutionService.SearchProjectEntries(AssemblyName assemblyName, String typeName, Boolean ignoreTypeCase, Assembly& assembly) at
Microsoft.VisualStudio.Design.VSTypeResolutionService.SearchEntries(AssemblyName assemblyName, String typeName, Boolean ignoreCase, Assembly& assembly, ReferenceType refType) at
Microsoft.VisualStudio.Design.VSTypeResolutionService.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, ReferenceType refType) at
Microsoft.VisualStudio.Design.Serialization.CodeDom.AggregateTypeResolutionService.GetType(String name, Boolean throwOnError, Boolean ignoreCase) at
Microsoft.VisualStudio.Design.Serialization.CodeDom.AggregateTypeResolutionService.GetType(String name, Boolean throwOnError) at
System.ComponentModel.Design.Serialization.CodeDomSerializerBase.GetType(ITypeResolutionService trs, String name, Dictionary`2 names) at
System.ComponentModel.Design.Serialization.CodeDomSerializerBase.FillStatementTable(IDesignerSerializationManager manager, IDictionary table, Dictionary`2 names, CodeStatementCollection statements, String className) at
System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.Deserialize(IDesignerSerializationManager manager, CodeTypeDeclaration declaration) at
System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager manager) at
Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager) at
Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.DeferredLoadHandler.Microsoft.VisualStudio.TextManager.Interop.IVsTextBufferDataEvents.OnLoadCompleted(Int32 fReload)