0

I have a problem regarding a public declaration in one project which makes reference to a class in a different project.

The parent project references the dependent project without problem. However, I'm getting a warning that Type member 'user' is not CLS-compliant. It's declared as

Public user As User

this declaration is made in the parent project. User is a class in the supporting project I can use the type on a form without fail. Now, I try to pass it off on another form - in the parent project:

Private oldUser As User
oldUser = frmUserMgt.user 

and the thing crashes. Stepping through the code shows oldUser is nothing.

I built a brand new solution and tested this exchange without fail. I've searched solution and project settings until I'm blue in the face and can't find a difference. It's a VS2012 VB solution. I can post as much code as needed if the above description isn't sufficient - any help will be greatly appreciated.

Damien_The_Unbeliever
  • 234,701
  • 27
  • 340
  • 448
BDFarm
  • 63
  • 1
  • 6
  • possible duplicate of [Base type is not CLS-compliant, what reasons of this warning?](http://stackoverflow.com/questions/4013087/base-type-is-not-cls-compliant-what-reasons-of-this-warning) – Tomas Pastircak Apr 22 '14 at 14:44
  • frmUserMgt is a *type name*, not an object reference. This syntax is supported anyway in VB.NET but forever causes the kind of mishap you describe. It has a knack for creating a *new* instance of the frmUserMgt class, especially when you run the code on a worker thread. This doesn't otherwise do anything to solve the warning. – Hans Passant Apr 22 '14 at 16:34
  • Hans, if it is causing a New instance of frmUserMgt what can I do to fix it so it's passing the correct instance. – BDFarm Apr 23 '14 at 13:02

0 Answers0