名称“XYZ"名称空间“clr-namespace:ABC"中不存在; [英] The name "XYZ" does not exist in the namespace "clr-namespace:ABC"

查看:38
本文介绍了名称“XYZ"名称空间“clr-namespace:ABC"中不存在;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正致力于创建一些标记扩展,并开始出现非常奇怪的 VS 行为.我在单独的解决方案中提取并指出了问题.问题是 VS 无法在 XAML 中创建 CLR 对象.

I was working on creating some markup extensions and started to get very weird VS behaviours. I have extracted and pinpointed the issue in the separate solution. Problem is that VS can't create a CLR object in XAML.

这是:

查看:

<Window x:Class="WpfApplication4.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:wpfApplication4="clr-namespace:WpfApplication4">
    <Window.Resources>
        <wpfApplication4:Dog x:Key="doggy" />
    </Window.Resources>
    <Grid />
</Window>

背后的代码:

using System.Windows;

namespace WpfApplication4
{
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
    }
}

狗类:

namespace WpfApplication4
{
    public class Dog
    {

    }
}

App.Xaml(App.Xaml.cs 中没有代码):

<Application x:Class="WpfApplication4.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             StartupUri="MainWindow.xaml">
    <Application.Resources>

    </Application.Resources>
</Application>

我遇到的异常:

Error   1   The name "Dog" does not exist in the namespace "clr-namespace:WpfApplication4". \hopr1folders$vxkDocumentsVisual Studio 2012ProjectsWpfApplication4MainWindow.xaml  6   9   WpfApplication4

我能够运行解决方案,但设计器因无效标记"错误而失败有什么想法吗?

I am able to run solution, but designer fails with "Invalid Markup" error Any ideas?

编辑

我正在运行 VS 2012 Update 2同样的解决方案在 VS 2012 Update 1 中工作

I am running VS 2012 Update 2 The same solution work in VS 2012 Update 1

推荐答案

您的解决方案正在网络共享上运行..Net(和 Visual Studio)应用程序在网络共享上运行时可能会遇到权限/访问问题.

Your solution is running on a network share. .Net (and Visual Studio) applications can run into permission / access issues when running on a network share.

将您的解决方案复制到本地驱动器(完全信任),您应该没问题.

Copy your solution to a local drive (with full trust) and you should be fine.

有可能让网络驱动器在完全信任的情况下工作——你可以在 StackOverflow 和其他地方找到答案——但根据我的经验,当我这样做时,我总是遇到障碍,所以尽量避免它,除非它是绝对的对手头的问题至关重要.

It is possible to get a network drive working with full trust - you can find answers for this on StackOverflow and other places - but in my experience I keep running into obstacles when I do this, so try to avoid it unless it's absolutely critical to the problem at hand.

例如这个问题给出了如何做到这一点的说明:

E.g. this question gives instructions about how to do this:

给予 FullTrustVisual Studio 2012 和 .Net 4.0 的 UNC 共享

我只在 VS2010 上尝试过这个,所以(如链接中所示)你可能会在 2012 中获得更好的乐趣.

I've only ever tried this with VS2010 so (as indicated in the link) you might have better joy with 2012.

这篇关于名称“XYZ"名称空间“clr-namespace:ABC"中不存在;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆