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

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.

Related

InitializeComponent does not exist

InitializeComponent();
This code line appeared in all my Xaml pages' constructors in code behind.
It throws the following error:
InitializeComponent does not exist.
Now I cannot debug any page in my project although I have commented out this line.
How can I fix this?
Any help would be greatly appreciated.
Note: I'm using Xamarin Forms Portable project.
Update: When I comment out this line and run the pages, only an empty screen shows up in both IOS and Android although my pages were working correctly without error before.
Update 2: now the InitializeComponent lines are disappeared but the pages that I debug are still totally blank.
I have asked a question about this new problem on here.
I had also the same problem in Xamarin Forms Application.I fixed it by changing the Build Action to:
Embedded resource
for .xaml and .cs file both using property window.
Hope it may help you.
Change something in the page, then save it. Scarily this resolves the issue sometime.
If that doesn't work.
Update your nugget packages so Xam Forms is the latest.
"Clean" your project
Go to your project dir and delete the bin and obj from your projects via File Explorer.
Rebuild it.
Good luck.
Be sure that your Xaml page has property Custom Tool set to MSBuild:UpdateDesignTimeXaml
'Its not an issue. You can try to build your solution. Hopefully it will bulid perfectly. Most of the time I also get red under line on InitializeComponent(); like you same. Its a problem of Xamarin studio and Visual studio'
Is it the first XAML page you create in the project? or you created other pages and they don't contain this problem?
you can Check the comments here: http://forums.xamarin.com/discussion/17638/initializecomponent-does-not-exist/p4
Have you renamed your page? All XAML pages have a viewable partial class (the one you enter your logic code in to) and a hidden, system generated partial class.
If you renamed the class but did not use the VS rename macro, your system generated partial class no longer matches your editable partial class.
Try running 'Clean Solution' and 'Rebuild Solution' (both in the 'Build' menu) to see if VS can automatically detect and fix this for you.
If that doesn't work, make sure your pages are set as partial classes e.g. public partial class MyPage : Page
If you still have no luck, manually delete the 'obj' folder in your project's root folder, then rebuild again.
Simple trick:
Just edit your Xaml code..(Put space also enough..But need editing)
After edit the xaml page save project..
Now check error disappears..
In my case this was a result of intermediate build paths being too long for Windows. Moving my solution to just off the drive root C:\dev{solution} in my case solved the problem.
I had this problem because the namespace of my .xaml file did not match the namespace of the .xaml.cs file. Fixing the namespaces so they matched corrected the problem.

Xamarin Forms InitializeComponent does not exist

I am learning Xamarin Forms for Visual Studio 2015 and trying to create a simple Shared project using Xaml but I keep getting InitializeComponent does not exist (as well as any reference to Xaml controls in cs classes).
It is my understanding that in the latest versions of Xamarin, Xaml works in Shared Xamarin Forms Projects (and not only in PCL projects). I've tried running the latest betas that got released less than a month ago but still no luck.
Any advice is greatly appreciated.
Turns out I had to manually change the properties for all Xaml files like so:
Build Action: Embedded resource
Custom Tool: MSBuild:UpdateDesignTimeXaml
For some reason adding new Xaml forms files doesn't set these by default in VS2015 with latest Xamarin.
I had the same issue. And it turned out to be that fully qualified Class Name (x:Class attribute in the main node) in the XAML file must match exactly the xaml.cs file's name. I corrected the namespace casing and it worked!!
This happens when your XAML markup is invalid. There is a background compilation task that parses the XAML file and generates a code file (this is normally hidden from the developer) which declares those control references. If your XAML is not valid then this task will fail silently, and your first hints are the symptoms you describe.
Comment out the contents of your XAML file using standard XML comment syntax (wrap it with <!-- and -->), then rebuild your project to clear out all of the errors. You may also need to comment out some code in your .cs files temporarily to get it to build. Once you get it building, then you can go back and start uncommenting your XAML until you find the part that was breaking it.
Try it:
Open the Package Manager Console, put the follow line:
update-package -project your_pcl_project_name -reinstall

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)

Adding DLL reference to VB.NET project

Just to start off, this question does seem very similar to another post Add the DLL (lame_enc.dll) reference to my project, but I haven't been able to successfully apply that answer. I am pretty new to VB.NET so it is very possible I'm simply missing something obvious.
I am trying to link a DLL to a VB.NET 2010 project to allow my VB app to play *.ogg files. I followed some other advice here on the forums and downloaded FMOD's FMOD Ex Programmers API. I am trying to now reference that functionality. These appear to be the files I need to somehow reference.
C:\Program Files (x86)\FMOD SoundSystem\FMOD Programmers API Windows\api\fmodex64.dll.
C:\Program Files (x86)\FMOD SoundSystem\FMOD Programmers API Windows\api\libfmodex64_vc.lib.
I haven't discovered how to add a *.lib reference (or the equivalent), but selecting the DLL as a reference gives the following error.
A reference to 'C:\Program Files (x86)\FMOD SoundSystem\FMOD
Programmers API Windows\api\fmodex64.dll' could not be added. Please
make sure that the file is accessible, and that it is a valid assembly
or COM component.
I'm not sure what I could be missing. Any ideas? Thanks!
In Solution Explorer, double-click the My Project node for the project.
In the Project Designer, click the References tab.
Click the Add button to open the Add Reference dialog box.
In the Add Reference dialog box, select the tab indicating the type of component you want to reference.
Select the components you want to reference, then click OK.
Another approach I was trying is working for me. I found a site with a working example of a LibZPlay VB.NET sample ( http://planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=7789&lngWId=10 ). It runs under VS 2008 and I was able to adapt my project to use LibZPlay (open source library http://libzplay.sourceforge.net/WELCOME.html ) under VS 2008.
That is sufficient for me for now. Thanks for your advice. It was likely some configuration issue or misunderstanding on my end.
Using VB.net 2015 I (could not add or even find a System32 dll) as a reference using Solution Explorer, Tab References. Going to the MAIN Menu, Projects/Add References...
Used Browse and All the System32 dll were visible. Then I was able to load the needed dll.

VB NET class is recognized in VS, but I get a 'Type is Undefined' error on build

I am working on a VB NET project and had the strangest thing happen.
I created a class file(just like a dozen or so I have already created). I wrote in the code to access it. The autocomplete found the class, filled it in and colored it blue, just as it should.
But, when I run the app, I get a type is undefined error.
There is nothing in the class yet. And there is really no code to post..it is as straight forward as I described.
I tried restarting VS; Deleting and recreating the class; Deleting the class and creating a new one with a different name.
Is there something in the VB NET configuration I can check to see if it is not being added somewhere?
lee
Ok. I found the problem. I have 2 projects in one solution. They both share some classes that were trying to use my new classes. When I hit F5, both projects are compiled, and since I hadn't shared the classes with the second project, it errored.
So, now my question is changed; How do I specify to only build the specified Startup Project when debugging?
lee
Right click your solution -> properties -> configuration properties and untick everything you don't want to build.
And for your original question, check if build action on that files that don't compile is set to 'compile'