这是我的代码:
XElement itemsElement = new XElement("Items", string.Empty);
//some code
parentElement.Add(itemsElement);
Run Code Online (Sandbox Code Playgroud)
之后我得到了这个:
<Items xmlns=""></Items>
Run Code Online (Sandbox Code Playgroud)
父元素没有任何名称空间.我该怎么做才能获得Items没有空命名空间属性的元素?
我在LinqToXml中创建新元素时遇到问题.这是我的代码:
XNamespace xNam = "name";
XNamespace _schemaInstanceNamespace = @"http://www.w3.org/2001/XMLSchema-instance";
XElement orderElement = new XElement(xNam + "Example",
new XAttribute(XNamespace.Xmlns + "xsi", _schemaInstanceNamespace));
Run Code Online (Sandbox Code Playgroud)
我想得到这个:
<name:Example xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
Run Code Online (Sandbox Code Playgroud)
但在XML中我总是这样:
<Example xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="name">
Run Code Online (Sandbox Code Playgroud)
我做错了什么?
我在C#中有一个与PostgreSQL连接的简单应用程序。我想使用此应用程序创建图像并仅在docker上运行。
我使用时一切正常:
$ docker build
$ docker run postgres
$ docker run my_app
Run Code Online (Sandbox Code Playgroud)
此外,当我在应用程序目录中使用compose时,一切正常
$ docker-compose build
$ docker-compose up
Run Code Online (Sandbox Code Playgroud)
但是是否有机会将docker-compose用于我之前构建的映像?
我想将此图像发布到我的仓库中,而我团队的其他人只需下载并运行该图像(应用程序+数据库)。
当我执行compose-build并在下次compose运行my_app时,在连接数据库期间出现异常:
dbug: Npgsql.NpgsqlConnection[3]
Opening connection to database 'POSTGRES_USER' on server 'tcp://postgres:5432'.
Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.AggregateException: One or more errors occurred. (No such device or address) ---> System.Net.Internals.SocketExceptionFactory+ExtendedSocketException: No such device or address
Run Code Online (Sandbox Code Playgroud)
我当前的docker-compose.yml文件:
version: '2'
services:
web:
container_name: 'postgrescoreapp'
image: 'postgrescoreapp'
build:
context: .
dockerfile: Dockerfile
volumes: …Run Code Online (Sandbox Code Playgroud) 我有ArrayList.我想检查是否有任何值退出ArrayList.我想使用Any方法(来自System.Linq命名空间),但我只能使用它Array,而不是ArrayList.
有没有有效的方法来检查这个?
我想像这样制作xml元素:
<ElementName Type="FirstAttribute" Name="SecondAttribute">Value</Atrybut>
Run Code Online (Sandbox Code Playgroud)
现在我这样做:
XmlNode xmlAtrybutNode = xmlDoc.CreateElement("ElementName ");
_xmlAttr = xmlDoc.CreateAttribute("Type");
_xmlAttr.Value = "FirstAttribute";
xmlAtrybutNode.Attributes.Append(_xmlAttr);
_xmlAttr = xmlDoc.CreateAttribute("Name");
_xmlAttr.Value = "SecondAttribute";
xmlAtrybutNode.Attributes.Append(_xmlAttr);
xmlAtrybutNode.InnerText = !string.IsNullOrEmpty(Value)
? SetTextLength(Name, ValueLength)
: string.Empty;
Run Code Online (Sandbox Code Playgroud)
值是方法中的输入变量.是否有可能以另一种方式做到这一点?更有效率?我可以使用xmlWriter吗?现在我正在使用xmlDocument.
我正在尝试将Web服务称为几个小时.我添加了clientaccesspolicy.xml:
<?xml version="1.0" encoding="utf-8"?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from http-request-headers="*">
<domain uri="*"/>
</allow-from>
<grant-to>
<resource path="/" include-subpaths="true"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>
Run Code Online (Sandbox Code Playgroud)
和crossdomain.xml:
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-http-request-headers-from domain="*" headers="SOAPAction,Content-Type"/>
</cross-domain-policy>
Run Code Online (Sandbox Code Playgroud)
到我的网站的根目录.从IIS调用Web服务,它在这里工作.
但是,当我尝试从silverlight应用程序调用我的wcf Web服务时,我收到此错误:
远程服务器返回错误:NotFound.
这是来自Fiddler的日志:
a:InternalServiceFault由于内部错误,服务器无法处理请求.有关错误的更多信息,请在服务器上启用IncludeExceptionDetailInFaults(来自ServiceBehaviorAttribute或来自<serviceDebug>配置行为),以便将异常信息发送回客户端,或者根据Microsoft .NET Framework打开跟踪3.0 SDK文档并检查服务器跟踪日志.
这是代码,当我收到错误时:
public int EndUserExist(System.IAsyncResult result) {
object[] _args = new object[0];
int _result = ((int)(base.EndInvoke("UserExist", _args, result))); //Here
return _result;
}
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
我在C#中使用XDocument创建XML文档.我有个问题.
是
<Simple xmlns = "Example"></Simple>
Run Code Online (Sandbox Code Playgroud)
相当于
<Example:Simple></Example:Simple>
Run Code Online (Sandbox Code Playgroud)
?
我试图在C#中使用XNamespace和XElement获得第二个解决方案,但我只得到第一个.
我有样品课:
public class SampleClass
{
public Dictionary<string, List<string>> SampleProperties {get;set;}
}
Run Code Online (Sandbox Code Playgroud)
我想将这个类序列化为xml.我怎么能这样做?我想输出xml类似于这个例子:
<DataItem>
<key>
<value></value>
<value></value>
<value></value>
</key>
</DataItem>
Run Code Online (Sandbox Code Playgroud)
问候
我正在Oracle中编写一个事务.我可以在一个select语句中更改此事务中的隔离级别吗?现在我有Read Commit,我希望在事务中将此更改为可序列化,然后再返回读取提交.
最诚挚的问候,格雷戈里
我有很大问题...我的代码:
string doc = System.Text.Encoding.ASCII.GetString(stream);
Run Code Online (Sandbox Code Playgroud)
变量doc以第一个null(/0)字符结束(此时缺少大量数据).我想得到整个字符串.更重要的是,当我复制这段代码并在Visual Studio中立即运行时 - 一切都很好......
我做错了什么?
我有这个问题.我有一个arrayList,我想将一些对象复制到另一个.更重要的是,每个对象都有一个特定的属性,我将其用作过滤器进行复制.不幸的是,我必须使用.NET 1.1,所以我不能使用lamda表达式.
你有任何想法吗?我想要做到这一点.我有解决方案,只使用foreach循环,但我想尽可能优化这个优化.
对不起我的英语不好.
ArrayList list = new ArrayList();
//Insert to list few objects
ArrayList specificList = get few objects from list using filter. For example Object.Name
Run Code Online (Sandbox Code Playgroud) c# ×11
.net ×5
xml ×5
linq-to-xml ×3
.net-1.1 ×1
arraylist ×1
ascii ×1
c#-4.0 ×1
commit ×1
docker ×1
dockerfile ×1
oracle ×1
postgresql ×1
silverlight ×1
transactions ×1
wcf ×1
xelement ×1