Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4.5 > BOOK: Beginning ASP.NET 4.5 : in C# and VB
|
BOOK: Beginning ASP.NET 4.5 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4.5: in C# and VB by Imar Spaanjaars; ISBN: 978-1-118-31180-6
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4.5 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 29th, 2014, 08:08 AM
Registered User
 
Join Date: Aug 2014
Posts: 5
Thanks: 2
Thanked 0 Times in 0 Posts
Exclamation I cannot use "Imports" with my custom Namespace

Hi, Can someone help me, please? I set up a class file called Calculator.vb in the App_Code Folder.

Code:
Imports Microsoft.VisualBasic

Namespace Wrox.Samples

    Public Class Calculator


        Public Function Add(a As Double, b As Double) As Double
            Return a + b
        End Function

        Public Function Subtract(a As Double, b As Double) As Double
            Return a - b
        End Function

        Public Function Multiply(a As Double, b As Double) As Double
            Return a * b
        End Function

        Public Function Divide(a As Double, b As Double) As Double
            Return a / b
        End Function

    End Class

End Namespace
My problem is that when I try adding the following to the code behind page I get an error, "Wrox.Samples doesn't contain any public member or cannot be found....."

Code:
Imports Wrox.Samples
I am using Visual Studio Express 2013 for Web on Windows7 Home Premium.

I would be glad of any help,

Thanks,

OldTom
 
Old August 29th, 2014, 08:52 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

What happens if you remove the Imports statement from the Code Behind, then click on Calculator in the line that instantiates the new Calculator and then press Ctrl+Dot (Ctrl+.). Do you see a menu pop up that lets you correct the error?

If not, can you post the full code for the Code Behind of the Calculator web form?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
OldTom (August 29th, 2014)
 
Old August 29th, 2014, 10:00 AM
Registered User
 
Join Date: Aug 2014
Posts: 5
Thanks: 2
Thanked 0 Times in 0 Posts
Default

When I try to instantiate the new calculator it says Type "Calculator" is not defined.

Code:
Partial Class WebForms_CalculatorDemo
    Inherits System.Web.UI.Page
    Dim myCalculator As New Calculator()


End Class
To be honest I have more or less finished the book, and decided to create my own application and was making good progress, however when I ran into problems I went back to the example in the book. Is there a possibility that I corrupted my copy of Visual Studio and it needs to be reinstalled?

I have a screen shot of the open windows I could send you if I knew how?.

Thanks for your help, and thanks for a great book - I had to go over it a few times before it began to sink in - it keeps the brain active during retirement!
 
Old August 29th, 2014, 10:21 AM
Registered User
 
Join Date: Aug 2014
Posts: 5
Thanks: 2
Thanked 0 Times in 0 Posts
Default

Sorry, I forgot to say that the CTRL + . says
Change Calculator to Validator
Create "Class Calculator",
generate New Type
 
Old August 30th, 2014, 05:36 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi (old?) Tom,

Odd, this should work the way you're describing. Are you sure the code file is in the App_Code folder and has the appropriate .vb extension? Also, make sure you have no other errors in the site. To test this, choose Build from the Website or Project menu and then check the Error List window.

Quote:
I have a screen shot of the open windows I could send you if I knew how?
You can't, on this site. However, there are many sites where you can publicly upload pictures to. You can ten share a link here. You can also e-mail it to me directly. You'll find my e-mail address in the Introduction section of the book.
Quote:
Thanks for your help, and thanks for a great book - I had to go over it a few times before it began to sink in - it keeps the brain active during retirement!
Good to hear you like it so much!

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
OldTom (August 30th, 2014)
 
Old August 30th, 2014, 05:09 PM
Registered User
 
Join Date: Aug 2014
Posts: 5
Thanks: 2
Thanked 0 Times in 0 Posts
Smile Problem Solved!

Hi Imar,

As you suggested I tried "Build" and got an error message. Apparently when I was setting up an ADO.NET Entity Data Model, I must have selected c# instead of vb with the result that the entity designer was in c#. As the error message said two different languages are not allowed, as they need to be compiled together. I deleted the Entity Data Model and rebuilt it using vb. Now all is working correctly.

Thanks for all your help.

Best wishes,

OldTom
 
Old August 30th, 2014, 07:39 PM
Registered User
 
Join Date: Aug 2014
Posts: 5
Thanks: 2
Thanked 0 Times in 0 Posts
Smile

Methinks, funny, the problem with the code behind page did not arise until I tried to mix apples and oranges, as it were in the same folder i.e. the App_Code Folder. Anyway, it is a pity that all problems in life cannot be solved so simply.





Similar Threads
Thread Thread Starter Forum Replies Last Post
I want o remove the namespace prefix "ns1" from WS response [email protected] BOOK: Professional Java Development with the Spring Framework 0 January 24th, 2012 07:58 AM
MSXSL gives error message for "for" inside "select" ilyaz XSLT 1 December 9th, 2010 05:02 PM
Add a CheckBox DataColumn to my DataGridView, Null format: "" or "True" but Error: F ismailc C# 2005 0 September 25th, 2009 04:56 AM
"The type or namespace name 'TheBeerHouse' could not be found " philthy BOOK: ASP.NET MVC Website Programming Problem Design Solution ISBN: 9780470410950 1 July 15th, 2009 06:16 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.