-6

My сode is in VB6. I am getting Compile error: 'User-defined type not defined'. My code is

Option Explicit
Implements ObjectXControl
Dim ctxObject As ObjectContext.
GSerg
  • 76,472
  • 17
  • 159
  • 346
  • 4
    How can both the net and VB6 tags apply? – Ňɏssa Pøngjǣrdenlarp May 24 '17 at 18:20
  • 2
    Possible duplicate of [compile error: user-defined type not defined](https://stackoverflow.com/questions/20357567/compile-error-user-defined-type-not-defined) – Yannick Meeus May 24 '17 at 18:25
  • This is a .NET problem so this is a better previous question. https://stackoverflow.com/questions/18255335/type-is-not-defined-error-on-project-build – jac May 24 '17 at 21:20
  • @jac How do you now it's a .NET problem? `User-defined type not defined` is the literal error message from VB6. VB.NET's message mentions the type name. – GSerg May 24 '17 at 22:28
  • @GSerg The `Implements` keyword is not vb6. – jac May 24 '17 at 22:44
  • 1
    @jac Oh [yes it is](https://msdn.microsoft.com/en-us/library/aa243384(v=vs.60).aspx). – GSerg May 24 '17 at 22:55
  • @GSerg Thank you. I stand corrected. – jac May 24 '17 at 22:59
  • 2
    Implements is VB6, and .Net would use Option Explicit On. – Slugsie May 25 '17 at 08:04
  • 1
    @Santosh, where is ObjectContext defined? Are you missing a reference somewhere? Does VB6 offer ObjectContext as an option in Autocomplete? – Slugsie May 25 '17 at 08:06
  • 1
    @YannickMeeus I don't think it's helpful to mark this question as a duplicate of a question that's [specifically about a missing ADO reference](https://stackoverflow.com/questions/20357567/compile-error-user-defined-type-not-defined). This question is not about a missing ADO reference. The answer to the other question will not help the OP. It would be nice to have a canonical question & answer about generic missing references, where its not possible to identify what the missing reference is. In many cases hte missing reference is so well-know that you can guess what is (classic example, ADO) – MarkJ May 25 '17 at 11:32
  • @MarkJ Fair enough – Yannick Meeus May 25 '17 at 11:41
  • Isn't this as simple as a missed reference under projects->references? – Bill Hileman May 25 '17 at 15:19
  • I have searched Project >Components , but I did not find anything related. – Santosh Ashwin May 25 '17 at 20:09
  • This is a Classic ASP application with VB6 Code. Am not well versed with ASP and VB6 , Am not able to find the Error. Surprisingly , If I run the Code in Visual Basic Classic Module, it would show the error "Compile Error: User-defined type not declared". The Text "Dim ' ctxObject As ObjectContext' " is Highlighted. And when I copy/paste same code in Visual Basic Project, the code would get executed and Dll would be generated. The major issue is the dll when deployed with application to other servers wouldnot work and cause a pain. Can anyone help – Santosh Ashwin May 25 '17 at 20:15
  • Looks like ObjectContext is [something](https://stackoverflow.com/questions/8766401/what-library-does-objectcontext-come-from-in-vb5) to do with [COM+](https://msdn.microsoft.com/en-us/library/windows/desktop/ms685978(v=vs.85).aspx). Are you using COM+? – MarkJ May 26 '17 at 16:21

1 Answers1

0

You are probably missing a reference. Check in the VB6 IDE under Project-References and also Project-Components.

  • It may be telling you about a missing reference/component on that screen. This usually means you need to install something on your machine, such as an ActiveX control or a DLL. Sometimes it means you need to repair the installation of something, or make sure it is registered.
  • Perhaps you have copied some code into a project, and the code relies on a particular control/DLL that you do not have referenced. You need to find out which thing(s) it needs, if necessary install them, and you need to tick them in Project-References or Project-Components.
MarkJ
  • 30,070
  • 5
  • 68
  • 111