A Visual Studio Bug

I found a weird bug related to attempting to add an inherited control to a VS .NET project. Here are the steps to reproduce:


Here's how to recreate it in Visual Studion .NET 2003 using VB .NET:

  1. Create a new solution.
  2. Add a ClassLibrary project called ClassLibrary1.
  3. Add a ClassLibrary project called ClassLibrary2
  4. Add a WIndows Control project called WindowsControlLibrary1.
  5. In ClassLibrary2, add an interface called IParameter.
  6. In ClassLibrary1, add an interface called ITest.
  7. Add a single method to ITest: "Sub TestRoutine(obj as IParameter)"
  8. In the WindowsControlLibrary1 project, add a usercontrol called UserControl1.
  9. Go ahead and compile the program, and prove that you can "add an inherited control" and that the inheritance picker successfully findes UserControl1 and adds it to the dialog.
  10. In UserControl1, implement ITest. You don't need any code in the method; just include the stub.
  11. Now, recompile, and try to "add an inherited control" again.
  12. See the error:
  13. ---------------------------
    Assembly Load Error
    ---------------------------
    Unable to load assembly '<path>\WindowsControlLibrary1.dll'.  Ensure that the file is a valid .Net Framework assembly.
    ---------------------------
    OK  
    ---------------------------
  14. Now, if you move ITest to the Control Library or to ClassLibrary2, it will succeed again :-)
  15. Interestingly enough, if you change ITest.TestRoutine(obj as IParameter) to ITest.TestRoutine(), the inheritance picker will work again. 
  16. Also, if ITest.TestRoutine() is a function that returns type IParameter, the same problem will occur.

<Code>

ClassLibrary1

Public Interface ITest

Function Test() As ClassLibrary2.IParameter

'Sub TestRoutine(ByVal obj As ClassLibrary2.IParameter) ' Fails

'Sub TestRoutine() ' Passes

End Interface

ClassLibrary2

Public Interface IParameter

End Interface

WindowsControlLibrary1

Public Class UserControl1

Inherits UserControl

Implements ITest

'WINDOWS FORMS DESIGNER GENERATED CODE

'Public Sub TestRoutine(ByVal obj As ClassLibrary2.IParameter) Implements ITest.TestRoutine

' ' fails

'End Sub

Public Function Test() As IParameter Implements ITest.Test

' fails

End Function

'Public Sub TestRoutine() Implements ClassLibrary1.ITest.TestRoutine

' ' Passes

'End Sub

End Class

</Code>

Comments

# re: A Visual Studio Bug

Tuesday, October 11, 2005 4:08 PM by pop

hey check the microsoft kb or google , something like this was reported.just do some searching

# re: A Visual Studio Bug

Tuesday, October 11, 2005 4:10 PM by Chris McKenzie

I did. I didn't find anything in the knowledge base. Google gave me a whopping two pages of search results, all of which were other programmers complaining about the same problem--but no one having a solution, apparently. Further, I posted to two microsoft newsgroups about it.

I did file an official but report with Microsoft about the problem though.

# re: A Visual Studio Bug

Wednesday, June 06, 2007 9:01 AM by Manoliu Catalin

Hi Chris,

I encounter the same problem with VS.NET 2005 sp1. Have you found a solution to this problem?

If so, please help !

( cmanoliu @ bouyguestelecom . fr )

Regards,

Catalin

# &quot;Ensure that the file is a valid .Net Framework assembly. | keyongtech

Pingback from  &quot;Ensure that the file is a valid .Net Framework assembly. | keyongtech

Leave a Comment

(required) 
(required) 
(optional)
(required)