C#WPF生成错误:CS0234命名空间中不存在类型或命名空间名称**
几天来,我一直在研究这个错误,但我还没有找到解决办法 在我的项目“Arcanium”中,引发以下错误: 中不存在类型或命名空间名称“GameWindow” 命名空间“Arcanium.Arcanium.ClientSide”(是否缺少程序集 参考?) [编辑]在GameWindow.xaml的第8行抛出错误 以下是课程: GameWindow.xaml(Arcanium.Clientside):C#WPF生成错误:CS0234命名空间中不存在类型或命名空间名称**,c#,wpf,xaml,visual-studio-2017,C#,Wpf,Xaml,Visual Studio 2017,几天来,我一直在研究这个错误,但我还没有找到解决办法 在我的项目“Arcanium”中,引发以下错误: 中不存在类型或命名空间名称“GameWindow” 命名空间“Arcanium.Arcanium.ClientSide”(是否缺少程序集 参考?) [编辑]在GameWindow.xaml的第8行抛出错误 以下是课程: GameWindow.xaml(Arcanium.Clientside): GameWindow.xaml.cs(Arcanium.ClientSide): 使用Arca
GameWindow.xaml.cs(Arcanium.ClientSide):
使用Arcanium.ClientSide.Engine;
使用Arcanium.Engine.Graphics;
使用Arcanium.Engine.User;
使用制度;
使用System.Collections.Generic;
使用系统图;
使用System.Linq;
使用系统文本;
使用System.Threading.Tasks;
使用System.Windows;
使用System.Windows.Controls;
使用System.Windows.Data;
使用System.Windows.Documents;
使用System.Windows.Input;
使用System.Windows.Interop;
使用System.Windows.Media;
使用System.Windows.Media.Imaging;
使用System.Windows.Shapes;
名称空间Arcanium.ClientSide{
///
///GameWindow.xaml的交互逻辑
///
公共部分类GameWindow:窗口{
公共静态int-SizeX{get;private set;}
公共静态int-SizeY{get;private set;}
私有静态游戏窗口_窗口;
公共游戏窗口(){
初始化组件();
_窗口=这个;
}
公共静态无效绘图框(快速位图框){
_window.Background=新的ImageBrush(ImageSourceForBitmap(frame.GetBitmap());
frame.Dispose();
}
专用静态图像源ImageSourceForBitmap(位图bmp){
var handle=bmp.GetHbitmap();
试一试{
返回Imaging.CreateBitmapSourceFromHBitmap(handle、IntPtr.Zero、Int32Rect.Empty、BitmapSizeOptions.FromEmptyOptions());
}最后{NativeMethods.DeleteObject(handle);}
}
已激活私有void(对象发送方、事件参数){
SizeX=512;
SizeY=512;
Game.ActivateGameLoop();
}
私有void OnClosing(对象发送方,System.ComponentModel.CancelEventArgs e){
游戏。跑步=错误;
}
私有void OnKeyDown(对象发送方,KeyEventArgs e){
输入。手动键盘按键(e键);
}
私有void OnKeyUp(对象发送方,KeyEventArgs e){
输入。手柄键盘释放(e键);
}
私有void OnSizeChanged(对象发送方,SizeChangedEventArgs e){
抛出新的NotImplementedException();
}
}
}
(我想不出正确的格式,这是我第一次在这里问)
我已经试过几种方法了
有什么提示吗?如果从头开始重新创建一个新的XAML文件呢?很抱歉,我没有列出。已经试过几次了。一旦我添加回事件注册,错误就会再次出现。我会把它写进我的问题中,你的xaml和cs文件在一个空项目中运行良好。你需要寻找其他的东西。是否显示指向xaml文件的错误?是的,第8行,事件所在位置。Visual Studio的版本是什么?
<Window x:Name="Arcanium" x:Class="Arcanium.ClientSide.GameWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Arcanium.ClientSide"
mc:Ignorable="d"
Title="Arcanium" Height="512" Width="512" Activated="OnActivated" Closing="OnClosing" KeyDown="OnKeyDown" KeyUp="OnKeyUp" SizeChanged="OnSizeChanged">
<Grid>
</Grid>
using Arcanium.ClientSide.Engine;
using Arcanium.Engine.Graphics;
using Arcanium.Engine.User;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Arcanium.ClientSide {
/// <summary>
/// Interaction logic for GameWindow.xaml
/// </summary>
public partial class GameWindow : Window {
public static int SizeX { get; private set; }
public static int SizeY { get; private set; }
private static GameWindow _window;
public GameWindow() {
InitializeComponent();
_window = this;
}
public static void DrawFrame(FastBitmap frame) {
_window.Background = new ImageBrush(ImageSourceForBitmap(frame.GetBitmap()));
frame.Dispose();
}
private static ImageSource ImageSourceForBitmap(Bitmap bmp) {
var handle = bmp.GetHbitmap();
try {
return Imaging.CreateBitmapSourceFromHBitmap(handle, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
} finally { NativeMethods.DeleteObject(handle); }
}
private void OnActivated(object sender, EventArgs e) {
SizeX = 512;
SizeY = 512;
Game.ActivateGameLoop();
}
private void OnClosing(object sender, System.ComponentModel.CancelEventArgs e) {
Game.Running = false;
}
private void OnKeyDown(object sender, KeyEventArgs e) {
Input.HandleKeyboardPress(e.Key);
}
private void OnKeyUp(object sender, KeyEventArgs e) {
Input.HandleKeyboardRelease(e.Key);
}
private void OnSizeChanged(object sender, SizeChangedEventArgs e) {
throw new NotImplementedException();
}
}
}