我已经创建了一个windows phone7自定义类库,因为我还创建了App.xaml和App.xaml.cs文件(我已经将它们重命名为MiEngineApp.xaml,MiEngineApp.xaml.cs,我的类库的名称是MiEngine)。我已经在我的应用程序中引用了类库。
现在,在我的应用程序中,我想编写从类库的App.xaml.cs类(即MiEngineApp.xaml.cs)派生的App.xaml.cs类。当我创建项目时,默认情况下会创建App.xaml.cs。默认情况下是扩展应用程序类,我只是将其更改为MiEngineApp(应用程序-> MiEngineApp)。这样做之后,我编译了我的应用程序,它在App.g.i.cs文件中给出了一个错误。错误消息是“'MiApp.App‘的分部声明不能指定不同的基类”。如何解决这个错误!
发布于 2011-05-18 19:08:51
您还必须更改App.xaml文件。这将是您的MiEngine.xaml
<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="MiEngine.MiEngineApp"
>
<Application.Resources>
</Application.Resources>
</Application>和MiEngine.xaml.cs:
namespace MiEngine
{
public partial class MiEngineApp : Application
{
public MiEngineApp()
{这将是从(扩展)MiEngine.xaml继承的App.xaml:
<z:MiEngineApp xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="SilverlightApplication6.App"
xmlns:z="clr-namespace:MiEngine;assembly=MiEngine"
>
<z:MiEngineApp.Resources>
</z:MiEngineApp.Resources>
</z:MiEngineApp>注意z名称空间的使用,这样我就可以引用基类了。
以及相应的代码:
namespace SilverlightApplication6
{
public partial class App : MiEngineApp
{
public App()
{https://stackoverflow.com/questions/6043540
复制相似问题