 |
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
|
|
|
|
|

August 29th, 2014, 08:08 AM
|
|
Registered User
|
|
Join Date: Aug 2014
Posts: 5
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
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
|
|

August 29th, 2014, 08:52 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
|
The Following User Says Thank You to Imar For This Useful Post:
|
|
|

August 29th, 2014, 10:00 AM
|
|
Registered User
|
|
Join Date: Aug 2014
Posts: 5
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
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!
|
|

August 29th, 2014, 10:21 AM
|
|
Registered User
|
|
Join Date: Aug 2014
Posts: 5
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
Sorry, I forgot to say that the CTRL + . says
Change Calculator to Validator
Create "Class Calculator",
generate New Type
|
|

August 30th, 2014, 05:36 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
|
The Following User Says Thank You to Imar For This Useful Post:
|
|
|

August 30th, 2014, 05:09 PM
|
|
Registered User
|
|
Join Date: Aug 2014
Posts: 5
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
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
|
|

August 30th, 2014, 07:39 PM
|
|
Registered User
|
|
Join Date: Aug 2014
Posts: 5
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
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.
|
|
 |
|