I have already looked to similar answers and I don't know why I am still have this error:
Severity Code Description Project File Line Suppression State
Error CS0263 Partial declarations of 'MainPage' must not specify different base classes MyNavDraw.Android (my path ...)\MainPage.xaml.cs 13 Active
MainPage.xaml.cs:
namespace MyNavDraw
{
public partial class MainPage : MasterDetailPage
{
...
MainPage.xaml
<MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:MyNavDraw"
x:Class="MyNavDraw.MasterDetailPage">
<MasterDetailPage.Master>
...
What I tried so far:
In xaml I have replaced the tag to:
<we:MainPage ...
I checked "x:Class" and I think is correct the syntax, I have restarted the VS and I built again the solution.
I use Xamarin with VS 2017.
After a day (from this post question) I tried to put in comments the code of "MainPage.xaml" file. Then I saved it, I removed comments, saved it again and built the solution. I have a new error in built:
No way to resolve conflict between "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" and "mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e". Choosing "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" arbitrarily.
I have an other problem when I debug the app to my physical phone (android).
In My.Nav.Draw.Droid.MainPage.xaml.g.cs I have an exception Unhandled error.
global::Xamarin.Forms.Xaml.Extensions.LoadFromXaml(this, typeof(MainPage));
What can be wrong?
Try adding your project name before the namespace name, also update your xmlns:local line too:
<MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:MyProjectName.MyNavDraw;assembly:MyProjectName"
x:Class="MyProjectName.MyNavDraw.MasterDetailPage">
Related
Trying to deserialize Powershell logs using "PSSerializer.Deserialize(log) as PSObject;" but keep getting error:
"System.Xml.XmlException: 'Element 'Objs' with namespace name 'http://schemas.microsoft.com/powershell/2004/04' was not found. Line 1, position 2.'"
Log example:
"<Obj RefId=\"0\">
<MS>
<Obj N=\"PowerShell\" RefId=\"1\">
<MS>
<Obj N=\"Cmds\" RefId=\"2\">
<TN RefId=\"0\">
<T>System.Collections.Generic.List`1[[System.Management.Automation.PSObject, System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]</T>
<T>System.Object</T>
</TN>
<LST>
<Obj RefId=\"3\">
<MS> ......
Appending this worked for me:
<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04">
..Log...
</Objs>
I am using VS2015 with Resharper for WebAPI 2.0 project. Trying to use System.Net.Http.HttpRequestMessageExtensions.GetRequestContext gives me an error saying
Error CS0433 The type 'HttpRequestMessageExtensions' exists in both 'System.Net.Http.Formatting, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' and 'System.Web.Http, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
I've tried editing web.config to read
<compilation debug="true" targetFramework="4.5.1" batch="false" />
Also as suggested in numerous posts - restarted visual studio, clear resharper cache, rebuild the solution.
Nothing helps and I am still seeing this error. Any other suggestions?
You need to use a “extern alias” to manage two classes with the same namespace.
First, define de name of your custom alias in the properties of the assembly:
Then, in the code:
using System.Web.Mvc;
namespace WebApplication1.Controllers
{
extern alias Alias1;
extern alias Alias2;
using namespace1 = Alias1::System.Net.Http.HttpRequestMessageExtensions;
using namespace2 = Alias2::System.Net.Http.HttpRequestMessageExtensions;
public class HomeController : Controller
{
public void Test()
{
// ...
namespace1.GetRequestContext(request);
//namespace2.GetRequestContext(request); // error
}
When my Prism 6 WPF modular application using Unity is starting then "Prism.Modularity.ModuleTypeLoadingException" in Prism.Wpf.dll is thrown. Below is screen shot of the exception:
As you can see the exception throws when Bootstrepper.Run method is called. Below is the code of the Botstrapper:
namespace FlowmeterConfigurator
{
class Bootstrapper : UnityBootstrapper
{
protected override DependencyObject CreateShell()
{
return Container.Resolve<MainWindow>();
}
protected override void InitializeShell()
{
Application.Current.MainWindow.Show();
}
protected override IModuleCatalog CreateModuleCatalog()
{
return new ConfigurationModuleCatalog();
}
}
}
Solution of my application consists of three projects: main WPF project created with Prism Template Pack as Prism Unity App and two modules, each of which is created with Prism Template Pack as Prism Module. Both of the modules are registered in App.config file, please see below:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="modules" type="Prism.Modularity.ModulesConfigurationSection, Prism.Wpf"/>
</configSections>
<modules>
<module assemblyFile="Authorization.dll" moduleType="Authorization.AuthorizationModule, Authorization, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" moduleName="AuthorizationModule" startupLoaded="true" />
<module assemblyFile="Calibration.dll" moduleType="Calibration.CalibrationModule, Calibration, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" moduleName="CalibrationModule" startupLoaded="true" />
</modules>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>
The first module is called Authorization and its class is caled AuthorizationModule:
namespace Authorization
{
[Module(ModuleName = "AuthorizationModule", OnDemand = false)]
public class AuthorizationModule : IModule
{
. . . . .
}
}
The second module is called Calibration and its class is called CalibrationModule:
namespace Calibration
{
[Module(ModuleName = "CalibrationModule", OnDemand = false)]
public class CalibrationModule : IModule
{
. . . . .
}
}
When my application is starting then MainWindow is displayed for short time (less then 1 second) and after this short time interval ModuleTypeLoadingException related to CalibrationModule is thrown. It looks like that type for AuthorizationModule was loaded succsessfully but loading of type for CalibrationModule fails. Please help me to eliminate this error.
P.S. I've not defined any instance of IModuleManager in my application. May be I must define it somewhere in my application?
Exception says that prism can`t find .dll files.
Your .exe file and .dll files of modules should be in the same folder(according to your app.config in previous question);
Exception says that prism can`t find .dll files. These may not been found if the diffrent projects of the solution are not build with the same Target Framework version. I had this error, when the Module-project was build in .Net Framework 4.5.2, while the Main-project was in 4.5.1.
Correct/Align the Target Framework version, exit Visual Studio, reenter, rebuild. Then the error was gone.
Mostly there are a multitude of reasons for an Exception.
.exe and .dll should be in same folder to avoid this exception that can be achieved in below two ways
1) Go to module project properties -> Build Events ->Post build event command line and
paste the below code
copy "$(TargetPath)" "$(SolutionDir)MainWPFProject\bin\$(ConfigurationName)"
MainWPFProject in above code means project having App.config file.
2) Copy dependent module .dll manually
I have one solution with three projects.
DomainModel (C# Library with ADO.NET Entity Framework)
DomainModelTest (Unit Testing for Business Logic)
WebApp (Using DomainModel)
For some reason, I cannot even bring the view if I pass any of the objects in the DomainModel, not even simple. I get the error below:
Any ideas?
Compiler Error Message: CS0012: The
type
'System.Data.Objects.DataClasses.EntityObject'
is defined in an assembly that is not
referenced. You must add a reference
to assembly 'System.Data.Entity,
Version=3.5.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089'.
Source Error:
Line 146: Line 147:
[System.Runtime.CompilerServices.CompilerGlobalScopeAttribute()]
Line 148: public class
views_home_index_aspx :
System.Web.Mvc.ViewPage,
System.Web.SessionState.IRequiresSessionState,
System.Web.IHttpHandler { Line 149:
Line 150: private static bool
#__initialized;
I thought this might be helpful, the actual error comes up on the Default.aspx file in the line pointed below:
public partial class _Default : Page
{
public void Page_Load(object sender, System.EventArgs e)
{
// Change the current path so that the Routing handler can correctly interpret
// the request, then restore the original path so that the OutputCache module
// can correctly process the response (if caching is enabled).
string originalPath = Request.Path;
HttpContext.Current.RewritePath(Request.ApplicationPath, false);
IHttpHandler httpHandler = new MvcHttpHandler();
httpHandler.ProcessRequest(HttpContext.Current); //**HERE**
HttpContext.Current.RewritePath(originalPath, false);
}
}
Try adding the reference in your web.config, in the < assemblies > section.
In web.config Add this
<configuration>
<system.web>
<compilation>
<assemblies>
<add assembly="System.Data.Entity, Version=3.5.0.0, Culture=neutral,PublicKeyToken=b77a5c561934e089"/>
</assemblies>
</compilation>
</system.web>
</configuration>
You can also add an empty ADO.NET Entity Data Model to your web-project, and then delete it. It will add the necessary references for you.
Even though the solution is so obvious I should have never have posted this, I'm leaving it up as a reminder and a useful point of reference to others.
I've got the following in my app.config file:
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core"/>
<section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core" />
</sectionGroup>
Followed by:
<spring>
<context>
<resource uri="config://spring/objects"/>
</context>
<objects xmlns="http://www.springframework.net">
<object name="mediaLibrary" type="AlbumLibraryWPF.AlbumLibrary, AlbumLibraryWPF"/>
</objects>
</spring>
Then in my app I've got:
using Spring.Context;
using Spring.Context.Support;
public partial class AlbumChecker : Window
{
private DataTable dataTable;
private Library library;
private Thread libraryThread;
public AlbumChecker()
{
InitializeComponent();
CreateToolTips();
IApplicationContext ctx = ContextRegistry.GetContext();
library = (Library)ctx.GetObject("mediaLibrary");
// Other initialisation
}
// Other code
}
It all compiles quite nicely, however, I'm getting an exception raised on the call to GetContext():
Error creating context 'spring.root': Could not load type from string value
'AlbumLibraryWPF.AlbumLibrary, AlbumLibraryWPF'.
I've checked the Spring.NET documentation and can't see what I'm doing wrong - but I clearly have got something wrong, otherwise it wouldn't raise the exception!
AlbumLibraryWPF is the namespace and AlbumLibraryWPF.AlbumLibrary is the fully qualified name of the class I want to instantiate. I'm guessing that it's this I've got wrong, but can't see how.
I feel such a fool.
It was because I'd failed to copy the AlbumLibrary.dll to the correct output directory. That meant that Spring couldn't find it - even after I'd fixed the assembly name problem Kent highlighted.
The name after the comma should be the assembly name, which is not necessarily the same as the namespace name.
I was getting this error because by mistake there was a typo [!*2] in app.config file. Once I took that out , error went away. some thing like this
<context>
<!--<resource uri="~//Aspects.xml"/>-->
<!--<resource uri="~//Dao.xml"/>-->
<!--<resource uri="~//Spring.xml"/>-->
<resource uri="file://Spring.xml"/>
<resource uri="file://Dao.xml"/>
</context>
!*2
You should use tha id attribute instead of name:
<object id="mediaLibrary" type="AlbumLibraryWPF.AlbumLibrary, AlbumLibraryWPF"/>
Also it should be config://spring/objects instead of config://spring/obects.
You need to double check that you have a type called AlbumLibrary in AlbumLibraryWPF namespace defined in AlbumLibraryWPF assembly.
You can try change the type. The type="AlbumLibraryWPF.AlbumLibrary, AlbumLibraryWPF", first parameter means NameSpace and the second parameter (behind the dot) means Solution Name.
"AlbumLibraryWPF.AlbumLibrary" = NameSapce name
"AlbumLibraryWPF" = solution name
Open VS2012 or VS2010 with Administrator Permissions
Config: type="namespace.type, assembly"
Then try running your solution again.