Home » VB.Net

Type '' is not defined

To correct this error I use the given help that microsoft provides below and i am still getting the error messages can anyone assist me with the source codes if i send some code snippets?

Check that the type definition and its reference both use the same spelling.

Check that the type definition is accessible to the reference. For example, if the type is in another module and has been declared Private, move the type definition to the referencing module or declare it Public.

If the type is defined, but the object library or type library in which it is defined is not registered in Visual Basic, click Add Reference on the Project menu, and then select the appropriate object library or type library.


2 Answers Found


Answer 1

HI Dave,

Please post your code  and someone should be able to assist  you.




Answer 2

Hi David,

Could you please send  your code  snippets ? Thanks.

Best regards,
Alex Liang



When creating a PageFunction I get the error ... type "StructuredNavigationSample.CustomType" is not defined.


I am using VS2010 and Framework 4.

All my VB code is without a namespace declaration, the project has a root namespace declared as 'StructuredNavigationSample'.

I would be grateful for any suggestions as to what I am doing incorrectly ...

Sample code is as follows:


Public Class CustomType
    Public Property ctString As String
End Class

Called PageFunction xaml:

    Title="Page Function" WindowWidth="250" WindowHeight="150">

When a try to build/run I get the error "StructuredNavigationSample.CustomType" is not defined.



Hello everyone,

I've been having an issue with trying to run my SSIS package on a server, and it seems to be failing on the OLE DB Command step.  What we have in our SQL 2005 DB, is a User-Defined Data Type (base type char(7)) and the OLE DB Command is supposed to call a proc that passes in a value of this data type.

ie:  CREATE PROCEDURE myProcedure ( @passedInFromSSIS MY_DATATYPE ) AS ....

In my SSIS package, I have the type defined as DT_STR with a length of 7. 

Now, when I run the package locally (via Visual Studio), the process runs with success.  However, once the package is deployed on a server and run from an application (note: it is run under a different user), the process fails on a validation step with a "Invalid Parameter Number" error.

Now, if I change the input parameter in my proc to the base type of the user-defined data type, the process works again.

Has anybody run into a similar issue or know what may be causing this issue?  I first suspected perhaps I needed to grant permissions on the user-defined data type (since I was able to run it under my security context, but not under the application's), however noticed that there isn't security tied to the types. 

Any other thoughts?  Please let me know if you need further explanation. 



The business people at my shop would like actual development effort tracked closely, and to facilitate this, I'm customizing the Agile 5.0 template to add a new work item type called "Work". This is a simple object that I'd like to hang off of Tasks and Bugs so that developers can quickly log time (and a few other details) against a parent work item. To this end, I've successfully implemented a Task-Work child relationship (see XML below, excerpted from my Tasks work item). As you can see, my idea of implementing the relationship is simply throwing a tab onto the Task detail form.

First of all, am I reinventing the wheel when it comes to tracking actual hours? Is there some sort of feature that I missed?

Assuming the answer to that is no, then I'd like my new Work type to always be a child of a Task or a Bug. I never want it to be a free-standing orphan. I don't want you to even be able to create it at the top level - I want you to have to create it from the detail form of a Task or Bug. Is there some way that I can express this?

<Tab Label="Work">
	<Control Type="LinksControl" Name="Hierarchy" Label="Work performed on this incident:" LabelPosition="Top">
			<WorkItemTypeFilters FilterType="include">
				<Filter WorkItemType="Work" />
				<LinkColumn RefName="System.WorkItemType" />
				<LinkColumn RefName="System.Title" />							

Thanks in advance for any comments.



To correct this error I use the given help that microsoft provides below and i am still getting the error messages can anyone assist me with the source codes if i send some code snippets?

Check that the type definition and its reference both use the same spelling.

Check that the type definition is accessible to the reference. For example, if the type is in another module and has been declared Private, move the type definition to the referencing module or declare it Public.

If the type is defined, but the object library or type library in which it is defined is not registered in Visual Basic, click Add Reference on the Project menu, and then select the appropriate object library or type library.


Platform is Visual Studio 2010 Professional and Crystal Reports for VS2010 beta on a Windows 7 machine. I am new to using crystal reports with visual studio. I am trying to create a general report that just has a date and time ran as a Visual Basic .Net application. I create the crystal report, but when I run it I get 26 errors, most of which are "Type Not Defined". For instance "Type ReportClass not Defined" or "Type CrystalDecisions.CrystalReports.Engine.Secion not defined". What am I doing wrong here? Am I missing a reference that I need? Funny thing is when I do the same thing as a web page it works fine, it just doesn't work when doing it as a Windows Application.

look the sequence of print screens:
After i put the reference the problem like it solved, but qhen i try to compile he return... Any one know how to fix this?


 noticed that in crvs2010 when you select a date in the Start of range or end of range fields , the hour, minute and seconds default to the current military time, instead of 00.00.00 like it always has in all prior versions of crvs and the full version of cr.

Is this intentional or is it a bug? This is causing reports to no longer pick up all of the records that it should. Hopefully, this will be fixed before crvs 2010 goes into production.

I looked for a new option that would let me set the default hour, minute and seconds , but could not find one. If an opition exists for this, please let me know.

Any help would be greatly appreciated.

 if any one has solution of this error then please give solution.


My user defined data types are apparently not available to a particular user.

The user has access (select permission) on a view which outputs many fields of various UDT types.  But the user can't view these columns because of UDTs are not visible to the user.

How can I surface the UDTs to the restricted user?


Many thanks!




Could anyone please tell me on what would be the best way to model oracle's user defined table types in SQL Server 2008 ?





Hello, could you tell me how to define a generic type in xaml when I implement a custom host for activities??

<sapt:ToolboxItemWrapperAssemblyName="{StaticResource Assembly}"><sapt:ToolboxItemWrapper.ToolName>
Switch<T> ??
I am using a CLR User Defined Type in a database called 'Normal', and would like to access that data from a CLR Table-Valued Function.
I can construct an SqlDataReader instance that encapsulates the Normal data type, but I would like to run something a kin to this:

    int i = dataReader->GetInt32( 0 )

But for my UDT:

    Normal i = dataReader->GetNormal( 0 )

Only, there is no function GetNormal.  How do I get dataReader to read my defined type into a variable?


Hi all,

I've browsed a few related posts on this forum but none of them have a definitive answer.

Here's our problem:

We have a few services developed in Java that share a schema file. On this schema file we have the common types that will be used on all services. For instance, the Quote data transfer object, the Client DTO etc.

Each Java Service includes on its wsdl the very same schema definition.

When we generate the client proxies by using the Service Reference code generator, classes generated as interpreted as different types.

Notice there is a different wsdl per service all with the same included schema.xsd.

We tried manual generation with svcutil.exe for each service but still, the classes for each DTO are interpreted as different type definitions.

We ended up using the old wsdl.exe utility and generating a single client service file:

wsdl.exe /sharetypes /language:CS /namespace:Model.Quote.Services /urlkey:SOAPServiceBaseURL /baseurl:http://servername/node /out:.\ModelServices.cs /protocol:SOAP12 http://servername/node/ClientService?wsdl http://servername/node/QuoteService?wsdl http://servername/node/AnotherService?wsdl

With the wsdl client generation and the /sharetypes flag we solved the issue. However:

1. Having a single .cs file means we have to regenerate every proxy if one service interface changes. And it is a burden as we cannot version each service on its own.

2. It is not intuitive for new developers where the services are or how many are there or what operations are on each service. Having a single Service Reference item on the solution per web service allows the developer to check the Reference.cs file and check the operations and types or DTOs used, fairly independently from another developer and make the change requests to the Java team independently as well (changes on service operations not related with the DTOs)

3. Lack of separation of concerns, code clarity, you name it...


My questions:

1. How to share common types (common DTOs) on client proxies generated by the Service Reference Wizard? (VS2008 Pro)

2. How to do the same using svutil.exe?

3. Are we stuck with wsdl.exe? even on a .NET 3.5 project?


Thanks in advance,


Lizet P





I am trying to store an application setting of my own custom type, and it says its not defined when in fact it IS defined. The problem is that my project namespace is not listed under the browse window. If I reference my own namespace, it works, but i get a million compiler errors so that's not an option.


Anyone know how to properly reference custom types that are within your own projects' namespace so I can use them in Application.Settings?

for example, I have an enum type in a class:

publicenum Bind

I tried clicking browse in the 'type' drop down in the app settings tab, then typing "VoltGameEditor.Globals.Bind" (which is where it is located) as the object type. That's when I received that error.

System: VS2010 win7x64


Hello Sir,

i am using vb .net and importing excel sheet to ms access. i am doing this work very well. but i want that when a user select the excel file to import, than user must asked for the data types that he want for the different fields, by default when user imports the excel file it assign the text data type to text filed such as name and number data type to numeric field such as roll_no. but i want that user select the data type according to his need.

Please help me on this topic.

waiting for reply.

code that i use is to import file is given below:

Imports System.Data.OleDb
Imports excel = Microsoft.Office.Interop.Excel

Public Class Form2
    Dim app_path As String = System.Windows.Forms.Application.StartupPath & "\master_project_file.mdb"
    Dim FileName As String
    Dim tbname As String

    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim AccessConnection As New System.Data.OleDb.OleDbConnection

        Dim _conn As String

        Dim SchemaTable As DataTable

        AccessConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & app_path


        tbname = InputBox("Enter the table name")

        SchemaTable = AccessConnection.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Columns, New Object() {Nothing, Nothing, tbname})

        If SchemaTable.Rows.Count <> 0 Then

            MsgBox("Table Exists already")


            Dim OpenFileDialog As New OpenFileDialog
            OpenFileDialog.Title = "Open Database"
            OpenFileDialog.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.MyDocuments
            OpenFileDialog.Filter = "DataBase Files (*.xls)|*.xls"

            If (OpenFileDialog.ShowDialog(Me) = System.Windows.Forms.DialogResult.OK) Then
                FileName = OpenFileDialog.FileName

            End If

            Dim oXL As excel.Application = New excel.Application
            Dim oWB As excel.Workbook = oXL.Workbooks.Open(FileName)

            oXL.Visible = False

            For Each oSheet As excel.Worksheet In oWB.Sheets
            ComboBox1.SelectedIndex = 0
            oWB = Nothing
            oXL = Nothing
        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim cn As New OleDbConnection
        Dim cmd As New OleDbCommand
        cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & FileName & ";" & "Extended Properties=Excel 8.0;")
            cmd = New OleDbCommand("SELECT * INTO [MS Access;Database=" & app_path & "].[" & tbname & "] FROM [" & ComboBox1.Text & "$]", cn)
            '_command.CommandText = "SELECT * INTO [MS Access;Database=" & app_path & "].[" & tbname & "] FROM [Sheet1$]"
            MessageBox.Show("The Data  Imported Successfully!")

        Catch e1 As Exception
            MsgBox("The following error has occurred:" & vbNewLine _
    & Err.Number & " - " & Err.Description, _
    vbCritical, _
    "On Drive Change")
            'MessageBox.Show("Error!.Your Excel Spread Sheet has some problems.")

        End Try
    End Sub
End Class


Hi ,

 I have a user defined table type which i need to pass as input parameter to the stored procedure .How can i do that?


We would like to be able to create a table-valued function on a user defined type.  We would like the syntax in SQL to look like it works for the XML nodes function:


DECLARE @myXml XML = '<a><b>1</b><b>2</b><b>3</b></a>' ;
SELECT  node.query('text()')
FROM    @myXml.nodes('a/b') nodes (node) ;


In other words, in the FROM clause, we can access the "nodes" method of the xml variable and it returns a rowset.



Is it possible to script out the User Defined Data Types via SMO in .NET and specifically VB.Net?  I have not been able to find some examples on how to do this.  If you have some experience with this, please
post some examples or provide links where I can find this information.

Thank you in advance.



I've been searching for several days now looking for threads / solutions in regards to a Report Viewer Problem.

OS - Windows Server 2008 all updates installed
DN FW - 3.5SP1 and 4.0
ReportViewer.exe was and is installed (Version 10.0.30319.1)
The ReportViewer Assemblies are in the GAC
The project is a Visual Studio 2010 project
The application is running in it's own App Pool with the 4.0 framework in integrated mode

In order to pin this down I have reduced a test project to an empty page with a Report Viewer Control and a Button. There is no DataSource and no report associated with the viewer, just the empty viewer control.

The web application runs without errors on my dev box and on a new test environment (with the Web Server in a VM) that I set up to test with.

When I deploy to our test or staging servers the page fails with Java Script errors. The error that is the root cause is "Type is undefined" which is referring to Reserved.ReportViewerWebControl.axd.  When using the developer tools for IE the script is loaded but fails at Line 1 of the script Type.registerNamespace("Microsoft.Reporting.WebFormsClient"); with the message Type is undefined.

  'Type' ist undefiniert  Reserved.ReportViewerWebControl.axd?OpType=Resource&Version=10.0.30319.1&Name=ViewerScript, Zeile 1 Zeichen 1

When I call the ReportViewerWebControl.axd manually and download the script or load the images then these calls go through, so I assume that all is well there. I have uninstalled and reinstalled all the Frameworks and the ReportViewer.exe several times. A complete new install of the servers is not an option (since we can't do that on the live site either). There is an installation of Cold Fusion on the servers but I am aware of the caveats of this and remove the CF handlers for this application. All other script resources work OK. The web config has all ReportViewer assemblies and handlers as described in serveral locations.

/mip_reporting/Reserved.ReportViewerWebControl.axd?OpType=Resource&Version=10.0.30319.1&Name=ViewerScript downloads a script Reserved.ReportViewerWebControl.axd /mip_reporting/Reserved.ReportViewerWebControl.axd?OpType=Resource&Version=10.0.30319.1&Name=Microsoft. Reporting.WebForms.Icons.SpinningWheel.gif shows the gif etc.

The script manager is on the page and at the top.

I'm afraid I don't have any ideas anymore how to proceed or find the root of the problem. I would appreciate any help pointing in the right direction.


using System;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Web.Services.Description;
using System.IO;
using System.Text;

namespace FT
  publicclass FT : System.Web.UI.Page
    protectedvoid Page_Load(object sender, System.EventArgs e);
    privateconststring ConnStr = "Driver={SQLServer};Server=NYC-001;Database=muskrat;Uid=User;Pwd=password;";
    protected System.Web.UI.WebControls.Table Tbl;
    protected System.Web.UI.WebControls.Image Image1;
    privatestring SqlStr = string.Empty;
    privatevoid Page(object sender, System.EventArgs e)
      SqlConnection Cn = new SqlConnection(ConnStr);
        SqlStr = "Select RTRIM(LName) AS LName, RTRIM(FName) AS FName, e.Badge_Number, Office_Floor, Extension, e.Home_Office, e.Residence_Office, Comment, e.Residence_Office as office_code, e.Login, e.Password, e.Employee_ID, Flex_In FROM Employee E WHERE e.status = 'Active' ORDER BY LName";
        SqlCommand cmd = new SqlCommand(SqlStr, Cn);
        SqlDataReader rd = cmd.ExecuteReader();
        if (rd.HasRows)
          TableRow trH = new TableRow();
          TableCell tcH0 = new TableCell();
          tcH0.Text = "<B>Employee</B>";
          tcH0.Attributes.Add("width", "30%");
          tcH0.ForeColor = System.Drawing.Color.White;
          TableCell tcH1 = new TableCell();
          tcH1.Text = "<B>Extension</B>";
          tcH1.ForeColor = System.Drawing.Color.White;
          tcH1.Attributes.Add("width", "5%");
          TableCell tcH2 = new TableCell();
          tcH2.Text = "<B>Office</B>";
          tcH2.ForeColor = System.Drawing.Color.White;
          tcH2.Attributes.Add("width", "10%");
          TableCell tcH3 = new TableCell();
          tcH3.Text = "<B>Floor</B>";
          tcH3.ForeColor = System.Drawing.Color.White;
          tcH3.Attributes.Add("width", "5%");
          TableCell tcH4 = new TableCell();
          tcH4.Text = "<B>Location</B>";
          tcH4.ForeColor = System.Drawing.Color.White;
          tcH4.Attributes.Add("width", "10%");
          TableCell tcH5 = new TableCell();
          tcH5.Text = "<B>Comments</B>";
          tcH5.ForeColor = System.Drawing.Color.White;
          tcH5.Attributes.Add("width", "40%");
          TableRow trLn = new TableRow();
          TableCell tcLn = new TableCell();
          tcLn.Attributes.Add("colspan", "6");
          tcLn.Text = "<hr>";
          tcLn.ForeColor = System.Drawing.Color.Red;

          while (rd.Read())

            TableRow trD = new TableRow();
            if (rd["Flex_In"] == System.DBNull.Value)
              trD.ForeColor = System.Drawing.Color.White;
              switch (rd["Home_Office"].ToString().Trim())
                  trD.ForeColor = System.Drawing.Color.BlueViolet;
                  trD.ForeColor = System.Drawing.Color.Yellow;
                  trD.ForeColor = System.Drawing.Color.Green;
                  trD.ForeColor = System.Drawing.Color.Red;
            TableCell tcD0 = new TableCell();
            tcD0.Text = rd["LName"].ToString() + " " + rd["FName"].ToString();
            TableCell tcD1 = new TableCell();
            tcD1.Text = rd["Extension"].ToString();
            TableCell tcD2 = new TableCell();
            tcD2.Text = rd["Home_Office"].ToString();
            TableCell tcD3 = new TableCell();
            tcD3.Text = rd["Office_Floor"].ToString();
            TableCell tcD4 = new TableCell();
            tcD4.Text = rd["Residence_Office"].ToString();
            TableCell tcD5 = new TableCell();
            if (rd["Comment"].ToString() == string.Empty)
              tcD5.Text = "None";
              tcD5.Text = rd["Comment"].ToString();
      catch (Exception ex)
        Console.WriteLine("Some sort of error occured: " + ex.Message);
        Console.WriteLine("It's the end of our try block. Time to clean up!");

    #region Web Form Designer generated code
    overrideprotectedvoid OnInit(EventArgs e)
      //// CODEGEN: This call is required by the ASP.NET Web Form Designer./////InitializeComponent();base.OnInit(e);

    ///<summary>/// Required method for Designer support - do not modify/// the contents of this method with the code editor.///</summary>/// private void InitializeComponent();protectedoverridevoid OnInit(EventArgs e)
      this.Load += new System.EventHandler(this.Page_Load);




I get the following error message from the above code:

Error 1 Type 'FT.FT' already defines a member called 'OnInit' with the same parameter types S:\FT13\FT\FT\FT.aspx.cs 155 33 FT


Imagine this procedure:


CREATEPROCEDURE [dbo].[insertActive] (
	-- Add the parameters for the stored procedure here
	@p_data dbo.activeUpdate readonly)
ASBEGIN-- SET NOCOUNT ON added to prevent extra result sets from-- interfering with SELECT statements.insertinto dbo.active (name,stateid) selectname,stateid from @p_data

How can I get the ids of the rows that have been inserted?  I tried searching the net and the forums but could not find anything.

Thanks for any and all help,


Just to make sure I was using all the available tools for the right purpose, I have been going through all the tabs I haven't used in SSMS. I've managed to research what they all mean but two have me a little stumped. These two tabs are:

Quite hard to search for help on as the word default is used to explain a lot of different things!

[Database]->Programmability->Types->User-Defined Types
I understand what "User-Defined Table Types" and "User-Defined Date Types" are, so what goes in "User-Defined Types"?

Can anyone explain what these are? Thanks very much


I have created a user define Table Type with two columns viz. Id and Value (both are nullable). Now from my application I am passing a datatable with only one column and the column name is "Id".

My expectation was it would populate only the "Id" column with the values and keep the "Value" column NULL. 

But I am getting an error stating "Trying to pass a table valued parameter with 1 column(s) where the corresponding user-defined table type requires 2 column(s).

Is it possible to pass a one column datatable as a parameter to the 2 column user defined table type.

Regards, digital
Success is 3-D coz it demands Desire, Determination and Dedication.

<< Previous      Next >>

Microsoft   |   Windows   |   Visual Studio   |   Sharepoint   |   Azure