Xamarin namespace issues in XAML files when changing startup project in VS - xaml

I have issues with Xamarin in Visual studio 2017 15.8.0 Preview 4 (And all previous builds)
I have a Xamarin forms project with a Android Project and a UWP project, if I change the startup project to UWP and try to compile I get this error
Error Failed to resolve assembly: 'FoosballXamarin.Android,
Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null' FoosballXamarin.UWP ...\Views\LoginPage.xaml
And the XAML itself will give me errors on these lines
xmlns:viewModels="clr-namespace:FoosballXamarin.ViewModels;assembly=FoosballXamarin.Android"
xmlns:helpers="clr-namespace:FoosballXamarin.Helpers;assembly=FoosballXamarin.Android"
And want me to change them to
xmlns:viewModels="clr-namespace:FoosballXamarin.ViewModels;assembly=FoosballXamarin.UWP"
xmlns:helpers="clr-namespace:FoosballXamarin.Helpers;assembly=FoosballXamarin.UWP"
Is there a way to write it differently so I dont get this error every time?

Based on the errors you're seeing, I'm going to guess you have this configured as a shared project (not PCL/.netstandard). If that's the case, simplify the lines in the XAML file to:
xmlns:viewModels="clr-namespace:FoosballXamarin.ViewModels"
xmlns:helpers="clr-namespace:FoosballXamarin.Helpers"
In other words, just remove the assembly= part. If you don't specify the assembly on the xmlns line, it will assume the namespace is the same assembly as the XAML file. So you only need to include it if it's in a different assembly.
Since shared projects include the XAML file in multiple assemblies (one per platform), you pretty much have to omit the assembly= on the xmlns declaration for namespaces/types in the same assembly.

Related

Building VSIX project in Release does not create a VSIX file anymore, just a DLL

I think the title is pretty clear. I always build in Release mode and upload the created VSIX file to the VS Marketplace.
Since today, it just creates a .dll file when I build in Release mode, no VSIX is generated. Also,in Debug I cannot set break points anymore, symbols won't load.
After reverting the commit (5 lines of code) to the previous version the problem still occurs.
I have no idea what could have caused this. Anyone experienced this before and what can I try to resolve this?
Edit:
This shows up in the build log, can this be the cause?
warning CS1762: A reference was created to embedded interop assembly 'EnvDTE, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' because of an indirect reference to that assembly created by assembly 'Microsoft.VisualStudio.Shell.15.0, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Consider changing the 'Embed Interop Types' property on either assembly
When I set the Embed Interop Types property to true on the EnvDTE assembly I get service can not be embedded errors throughout the package code.
I tried creating new VSIX projects or opening older ones, no issues there, it creates a .VSIX file when building in release mode. Comparing the CSPROJ files and configuration shows no difference.

VB 2015 build error: Conflicting options specified: Win32 resource file; Win32 manifest

I have a vb.net WinForms project that was originally developed in VS2010, and I'm now trying to work on in VS2015. However, without changing anything, VS2015 will not compile it. It initially returned 2 errors:
Error BC2023 cannot specify both /win32icon and /win32resource
Error BC37216 Conflicting options specified: Win32 resource file; Win32 manifest
I could (temporarily) get rid of the first one by removing the icon specified in Project properties > Application > Icon. But I can't see how to eliminate the second. Googling the second error seems to return nothing meaningful at all.
The error message clearly comes from the VB compiler itself, but I'm not aware, using the IDE, how to "specify" either a manifest or a resource file. I presume the manifest accessed by clicking on Project properties > Application > View Windows Settings is the manifest it refers to. However even temporarily deleting this file had no effect.
Is there any way to resolve this build error?

doing msbuild from the command line: getting errors for the referenced namespace 'Microsoft.VisualStudio.TestTools'

i'm compiling a .net 3.5 solution with msbuild with this line of code:
msbuild.exe n:\temp\Thisnight.sln /p:Configuration=Debug /v:diag
and it gives me this error:
error CS0234: The type or namespace name 'UnitTesting' does not exist in the namespace 'Microsoft.VisualStudio.TestTools' (are you missing an assembly reference?)
i've gotten the latest source which (off course) builds in VS2010 itself.
Can't seem to figure out what i'm missing here....
EDIT
Seeing higher up in the command window this message:
C:\Windows\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets : warning MSB3245: Could not resolve this reference.
Could not locate the assembly "Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutra
l, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
I don't think i have to include this DLL by my project (because it's a MS dll?)
EDIT
What i've seen now: all projects are for the .Net 3.5 framework, but the testproject (which is the one giving me problems) is for the .Net 4.0 framework.
And the weird thing is: i can't change it.
It's a vs2010 solution with web. webservice,winforms,dll,setup and testprojects
did you run vcvars32.bat in your cmd shell?
If you look at the Microsoft.Common.Targets file you will see :
<!--
The SearchPaths property is set to find assemblies in the following order:
(1) Files from current project - indicated by {CandidateAssemblyFiles}
(2) $(ReferencePath) - the reference path property, which comes from the .USER file.
(3) The hintpath from the referenced item itself, indicated by {HintPathFromItem}.
(4) The directory of MSBuild's "target" runtime from GetFrameworkPath.
The "target" runtime folder is the folder of the runtime that MSBuild is a part of.
(5) Registered assembly folders, indicated by {Registry:*,*,*}
(6) Legacy registered assembly folders, indicated by {AssemblyFolders}
(7) Resolve to the GAC.
(8) Treat the reference's Include as if it were a real file name.
(9) Look in the application's output folder (like bin\debug)
-->
VS runs MSBuild in its own environment, I don't know the differences either but did you try adding the lacking assembly path in command line by modifying the AssemblyFolders items. You have a tuto here : http://www.beefycode.com/post/Resolving-Binary-References-in-MSBuild.aspx .
Hope this helps.
try running:
msbuild /version
Make sure it's the 3.5 version and not something older.
Make sure the MS dll is here, or somewhere like that:
C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll

Weird problem with Visual Studio 2008 website reference

I'm trying to add a reference to the GAC version of System.Xml in a Visual Studio 2008 web site project. I right-click the project icon in the Solution Explorer, and click Property Pages. Under the References tree option, I click the 'Add' button on the right. I navigate to System.Xml in the .NET tab, and double click it (the Path it lists for System.Xml, C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.XML.dll, DOES exist). The dialog disappears, but... System.Xml does not get added as a reference! The list just stays the same.
I tried adding another .NET reference just to make sure others could be added OK, I added System.Web.RegularExpressions and it added fine. What on earth could be causing it not to add System.Xml?
Try to edit your vbproj file, and add
<Reference Include="System.Xml" />
I just created a ASP.NET Website with default language C# & .NET 2.0 as the target. I also observed that even if you try to add a reference to System.XML, you will not find one in the project proprieties page.
As far it goes for me, its as designed.
By default you can access all the default .NET namespaces (in your target version) by just adding "using NAMESPACE_NAME;" in you code behind.(System (& the sub namespaces like XML etc). ASP, Microsoft & MS) Only when you reference a third party .NET dll or something that's not default for an ASP.NET Website project (could not find the list of defaults on the net), then a new folder called bin is created & a copy of that dll is stored in it if it is not in GAC.
EDIT: Regarding not able to add a cs file to vb file, I just did that, & I could access System.Xml namespace in the vb file.
Well it looks like it might have had something to do with my trying to add a .cs file to a project where the rest of the files were in vb.net. Hmph, I thought one of the major benefits of .NET was you could easily mix languages. Oh well, I removed that and added these lines into my web.config file:
<add namespace="System.Xml"/>
and
<add assembly="System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
and now it compiles OK. I can access System.Xml from within VB code, so it looks like I'll have to translate the class I had from C# to VB.net. Hmph.

Mono - Could not load file or assembly

i just exported my project to my new imac an loaded my solution into monodevelop.
After the successfully compilation i started the project, and i always getting the same error.
** (/Library/Frameworks/Mono.framework/Versions/2.6.1/lib/mono/2.0/xsp2.exe:1576): WARNING **: The following assembly referenced from /private/var/folders/9y/9ypfv24bEwieHw+Yy+PUsU+++TI/-Tmp-/nhu-temp-aspnet-0/ebc9e2c6/assembly/shadow/7f5f6265/859daf16_fac2cd73_00000001/Centrism.Administration.UI.dll could not be loaded:
Assembly: Centrism.Core (assemblyref_index=3)
Version: 0.0.3688.40278
Public Key: (none)
The assembly was not found in the Global Assembly Cache, a path listed in the MONO_PATH environment variable, or in the location of the executing assembly (/var/folders/9y/9ypfv24bEwieHw+Yy+PUsU+++TI/-Tmp-/nhu-temp-aspnet-0/ebc9e2c6/assembly/shadow/7f5f6265/859daf16_fac2cd73_00000001/).
** (/Library/Frameworks/Mono.framework/Versions/2.6.1/lib/mono/2.0/xsp2.exe:1576): WARNING **: Could not load file or assembly 'Centrism.Core, Version=0.0.3688.40278, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
In other projects the assembly works correct and can be loaded.
I had the same problem with a dll that was in the same path as the application assembly, the problem was that the dll name had a different case than the expected one. So the Abc.dll was missing, in the folder it was named abc.dll, after renaming, it worked.
I guess I'm going to ask the obvious:
Do you have Centrism.Core.dll somewhere that Mono knows about and can get to?
If your project is referencing the Centrism.Administration.UI.dll, and it is not in the GAC on your iMac, the easiest solution would probably be to set the reference to that assembly to "Local Copy". For web projects, this will copy the assembly into the application's Bin directory, where xsp should be able to pick it up.
I had this error when adding a new assembly to an existing project (which itself was referenced by a unit test project).
Because the assembly wasn't included in both projects, the unit test would error out. The solution was to add a Copy tag to the project file:
<Copy SourceFiles="$(ProjectDir)\dlls\NewAssembly.dll" DestinationFolder="$(OutputPath)" SkipUnchangedFiles="true" />
Presumably it would also work to add the reference directly to the unit test (this reference is not used directly, so was able to avoid using above).