VB silverlight for windows phone "System.Xml.Linq" - vb.net

I am having this line in two of my windows phone applications :
Dim doc = XDocument.Parse(e.Result)
in the one of these apps it is working fine , in the other one it seems wrong ...
actually it cant find the object "XDocument"
When i am typing :
Imports System.Xml.Linq
it send me bug a warning :
Warning 2
Namespace or type specified in the Imports 'System.Xml.Linq' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases.
the only diference between the application that works and the applications that sends me back this bug and this worning is that the one is a simple windows phone page (the working one) and the other one is a panorama page :S
any ideas why i am having this warning ??
thank you

I think you might need to include the reference to System.XML.Linq first using Visual Studios "add reference" command (right click your project node in the project explorer, add reference).

Related

visual studio does not have System reference

i'm using visual studio enterprise 15 on windows 10 on my pc.
in the classes i use system functions without the imports.
for example:
Imports System.Data
Imports System.Data.SqlClient
Imports System.Xml
Imports WebControls
Public Class DataBaseTool
Dim NRnd As New Random
end class
i use Random without System reference.
if i load my project on a my 2nd pc, with visual studio community 15 on windows 7, i must explicit add import System
why?
so, i have more than 100 web pages...i cant't modify all.
thank you!
on win10
on win7
just to be clear, i have the same solution on 2 differents envirorments, but on win10 is fine, on win7 i have the problem with reference.
UPDATE
thanks to all who tried to help me.
i solved creating a new Website solution, then i dragged all files (except for webconfig) and all references are fine.
i don't know why, but it's running.
Open the References page of the project properties and you'll see a section showing the namespaces that are imported project-wide. The top half of the page is the referenced assemblies and the bottom half is the imported namespaces. You can add or remove imports by checking or unchecking items in that list. Anything checked in that list does not need to be imported at the file level.

Is there a way to stop Visual Studio from automatically adding an Imports line when I select a method from the navigation bar?

I'm using Visual Studio 2019 to write some VB code that consumes a couple of webservices. Whenever I select one of the methods from the navigation bar, Visual Studio insists on adding an Imports line at the top of the page. This is very annoying, particularly as there are a couple of structures in each web service with the same name, but different signatures and, because VS has replaced the fully-qualified names when it added the Imports, I'm getting errors.
I've tried manually removing the Imports and re-qualifying all the entries VS has bodged, but it all gets undone if I reselect a web service method from the navigation bar.
I'd prefer VS to leave the fully-qualified object names and not add an Imports line!
You could try an alias for the fully qualified name you wish to use.
Imports a = Fully.Qualified.Name
The in the code
a.MethodName

How do I get Visual Studio 2012 to generate code from a windows form design?

I am trying to add a simple windows form to my VB.Net project. I have used the designer to design the form how I want it with buttons, a text box and a Timer. The problem is when I try to view the code, there is only an empty class that looks like this:
Public Class MCastMain
End Class
I have set the application type to a windows form application in the project properties, and I have made a successful build of the application since doing so. I have been scrawling the internet and this forum for about half an hour now and I can't find one other person who is having this problem, nor can I find a tutorial that mentions any special steps that must be taken beyond what I have done. This is the first project I have done in Visual Studio.
I know this is probably stupid simple, but I have no idea what to do. Any help is appreciated as always.
Forms comes as partial class meaning the code is separated in two files.
The "empty" code you shown is from "mcastmain.vb" (if the file is named as the class).
With that one there is a (probably hidden) file "mcastmain.designer.vb" file which contains the generated code by the designer ; and is not meant to be modified (as any designer change will rewrite the file).
To show the hidden files you have to look in the solution explorer on the button on it's top there should be a "show all files" button. (it may be possible to do the same via the menu but I don't have VS right there to be sure where)

Using CustomMessageBox with WP8

In my WP8 app I have to use the CustomMessageBox. I use VB.NET and saw here I had to use the WP Toolkit which I added to my XAML like this :
xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
The thing I want to do is simple, it isn't complicated with other controls in the message box, just modifying the buttons text.
Now my problem is simple : I just can't create my CustomMessageBox Object. On the link I gave, you can see the example is :
CustomMessageBox messageBox = new CustomMessageBox()
with some parameters. It's C# but basically it should work with VB.NET this way :
Dim myMessageBox as CustomMessageBox = new CustomMessageBox()
But Visual Studio says "the type CustomMesageBox is not defined". Any idea ?
Thanks
Assuming you already downloaded the the toolkit and added it as project reference, possibly you missed adding Imports (using in C#):
Imports Microsoft.Phone.Controls

In a VB project, is it possible to have a resx file with the same name than a form?

Good Morning,
I'm working in a VB project (usually I work mostly on C#) and there is an issue at the compilation that I don't understand:
In my VB project I have a Windows Form (with its own Designer.vb and .resx) and a Resources file (with its Designer.vb), both have the same name, and it seems that it produce the following compilation error:
Error 13 The item "obj\Debug[projectName].[fileName].resources" was specified more than once in the "Resources" parameter. Duplicate items are not supported by the "Resources" parameter.
I can't change the name of one of them as it's an internal design pattern (and it works in C# projects).
Doesn't VB accept such pattern ? If yes, are there any workaround possible ?
Or do I have something wrong in one of my project files ?
Regards
Edit: As my problem may not be very clear, here is the pattern I have to respect in this project :
This doesn't compile. In VB only as I'm using this pattern in C# projects without any issues.
You probably have a duplicated entry inside the form.designer. I ran across this problem once
Goto to your Solution Explorer, Select your project and click on the show all files icon at the top of the Solution Explorer. You should then be able to expand out your form.vb to see all the sub files. Look for a frmMain.Designer.vb and check it for a duplicate resource entry. If that doesn't work try cleaning your Solution
Extracted from here, check the link it may help:
VB.net designer error
Edit: I would delete the form. Save the code behind and create it with another name pasting the code.
Finally I found where the problem was:
It was an issue with namespaces, as VB generated in VisualStudio doesn't provide any namespace by default in WinForms, ones I gave a namespace to the form and the designer of the form, and gave a different namespace to the second resx (via it's properties/Custom Tool Namespace) it compile.