我有一个WCF服务.
正常操作会看到服务器正在进行一些处理,通过回调将填充的XactTaskIn对象返回给客户端.我有这个工作正常.
我的问题是,当我尝试将returnData变量设置为填充的XactException并尝试通过回调将XactTaskIn发送回客户端时,我会抛出以下异常.
异常 - 不要求"数据协定名称为'XactException:http://schemas.datacontract.org/2004/07/'的类型'XactException'.请考虑使用DataContractResolver或将已知类型静态未知的任何类型添加到已知类型列表中 - 例如,通过使用KnownTypeAttribute属性或将它们添加到传递给DataContractSerializer的已知类型列表中." (System.Runtime.Serialization.SerializationException)异常消息="类型'XactException',数据协定名称为'XactException:http://schemas.datacontract.org/2004/07/'不是预期的.考虑使用DataContractResolver或添加任何静态地知道已知类型列表的类型 - 例如,通过使用KnownTypeAttribute属性或将它们添加到传递给DataContractSerializer的已知类型列表.",Exception Type ="System.Runtime.Serialization.SerializationException"
这是XactTaskIn类
[DataContract]
public class XactTaskIn
{
[DataMember]
public DateTime timeOut;
[DataMember]
public DateTime timeIn;
[DataMember]
public string name;
[DataMember]
public string responseTo;
[DataMember]
public String moduleFromName;
[DataMember]
public String moduleFromType;
[DataMember]
public String methodFromName;
[DataMember]
public object[] originalInputs;
[DataMember]
public String returnMethodToCall;
[DataMember]
public String returnModuleToCall;
[DataMember]
public object returnData;
public XactTaskIn(DateTime timeOut, DateTime timeIn, string name, string responseTo, String moduleFromName, String moduleFromType, String methodFromName, object[] originalInputs, …Run Code Online (Sandbox Code Playgroud) 我想以编程方式配置wpf网格.
我希望能够设置一个包含2列的网格,第一列占用可用空间的20%,第二列占80%.在xaml中我会使用*运算符,但我无法解决如何以编程方式执行此操作.
在Xaml我会这样做:
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition width="20*" />
<ColumnDefinition width="80*" />
</Grid>
Run Code Online (Sandbox Code Playgroud)
在我想要的代码中:
Grid grid = new Grid();
grid.ColumnDefinitions.Add( new ColumnDefinition(20*) );
grid.ColumnDefinitions.Add( new ColumnDefinition(80*) );
Run Code Online (Sandbox Code Playgroud)
请有人建议.
使用Windows安装程序部署程序时,如何设置默认安装路径.
我有一个作为WPF应用程序的ac #project,但我现在想把它构建为一个dll.我以前通过从项目中删除app.xaml并将其构建类型设置为dll来完成此操作.
我现在的问题是app.xaml包含一些xaml来实例化应用程序变量.为了解决这个问题,我试图以编程方式在将要调用的第一个xaml窗口中设置这些应用程序变量.
我试图在代码中模拟的xaml是:
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources/Styles/Shared.xaml"/>
<ResourceDictionary Source="Resources/Styles/ToolBar.xaml"/>
<ResourceDictionary Source="Resources/Styles/GroupBox.xaml"/>
<ResourceDictionary Source="Resources/Styles/ZoomBox.xaml"/>
<ResourceDictionary Source="Resources/Styles/ScrollBar.xaml"/>
<ResourceDictionary Source="Resources/Styles/Expander.xaml"/>
<ResourceDictionary Source="Resources/ApplicationToolbar.xaml"/>
<ResourceDictionary Source="Resources/DesignerItem.xaml"/>
<ResourceDictionary Source="Resources/Styles/ToolboxItem.xaml"/>
<ResourceDictionary Source="Resources/Styles/Toolbox.xaml"/>
<ResourceDictionary Source="Resources/Connection.xaml"/>
<ResourceDictionary Source="Resources/Slider.xaml"/>
<ResourceDictionary Source="Resources/ScrollViewer.xaml"/>
<ResourceDictionary Source="Resources/StatusBar.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
ResourceDictionary myResourceDictionary = new ResourceDictionary();
myResourceDictionary.Source = new Uri("C:\\Resources\\Styles\\Shared.xaml");
Application.Current.Resources.MergedDictionaries.Add(myResourceDictionary);
myResourceDictionary.Source = new Uri("C:\\Resources\\Styles\\ToolBar.xaml");
Application.Current.Resources.MergedDictionaries.Add(myResourceDictionary);
myResourceDictionary.Source = new Uri("C:\\Resources\\Styles\\GroupBox.xaml");
Application.Current.Resources.MergedDictionaries.Add(myResourceDictionary);
myResourceDictionary.Source = new Uri("C:\\Resources\\Styles\\ZoomBox.xaml");
Application.Current.Resources.MergedDictionaries.Add(myResourceDictionary);
myResourceDictionary.Source = new Uri("C:\\Resources\\Styles\\ScrollBar.xaml");
Application.Current.Resources.MergedDictionaries.Add(myResourceDictionary);
myResourceDictionary.Source = new Uri("C:\\Resources\\Styles\\Expander.xaml");
Application.Current.Resources.MergedDictionaries.Add(myResourceDictionary);
myResourceDictionary.Source = new Uri("C:\\Resources\\ApplicationToolbar.xaml");
Application.Current.Resources.MergedDictionaries.Add(myResourceDictionary);
myResourceDictionary.Source …Run Code Online (Sandbox Code Playgroud) 我有一个vs2010 c#解决方案昨天工作正常.
当我今天尝试运行一个调试实例时,我一直在处理一个SEHException未处理的问题.
InitializeComponent在启动表单的方法中抛出此错误.
有任何想法吗?
这是堆栈跟踪:
System.Runtime.InteropServices.SEHException was unhandled
Message=External component has thrown an exception.
Source=System.Drawing
ErrorCode=-2147467259
StackTrace:
at System.Drawing.SafeNativeMethods.Gdip.GdipCreateFontFromLogfontW(HandleRef hdc, Object lf, IntPtr& font)
at System.Drawing.Font.FromLogFont(Object lf, IntPtr hdc)
at System.Drawing.Font.FromHfont(IntPtr hfont)
at System.Drawing.SystemFonts.get_DefaultFont()
at System.Windows.Forms.Control.get_DefaultFont()
at System.Windows.Forms.Control.GetDefaultFontHandleWrapper()
at System.Windows.Forms.Control.get_FontHandle()
at System.Windows.Forms.ContainerControl.GetFontAutoScaleDimensions()
at System.Windows.Forms.ContainerControl.get_CurrentAutoScaleDimensions()
at System.Windows.Forms.ContainerControl.get_AutoScaleFactor()
at System.Windows.Forms.ContainerControl.PerformAutoScale(Boolean includedBounds, Boolean excludedBounds)
at System.Windows.Forms.ContainerControl.PerformNeededAutoScaleOnLayout()
at System.Windows.Forms.Form.OnLayout(LayoutEventArgs levent)
at System.Windows.Forms.Control.PerformLayout(LayoutEventArgs args)
at System.Windows.Forms.Control.System.Windows.Forms.Layout.IArrangedElement.PerformLayout(IArrangedElement affectedElement, String affectedProperty)
at System.Windows.Forms.ContainerControl.LayoutScalingNeeded()
at System.Windows.Forms.ContainerControl.set_AutoScaleMode(AutoScaleMode value)
at FirstWindow.Form1.InitializeComponent() in C:\Users\Ash\Documents\Visual Studio 2010\Projects\FrameworkClientV2 - …Run Code Online (Sandbox Code Playgroud) 我有一个绑定值,返回一个int,表示我没有分配给元素的左右边距的值.
继承人我尝试过但它不会编译.
如果我设置整个边距,它可以工作,但我只想要左右.
XAML:
<Image x:Name="_image" Source="mat.png" Margin="{Binding EditorRow.BondIndent},0,{Binding EditorRow.BondIndent},0" />
Run Code Online (Sandbox Code Playgroud)
类:
public int BondIndent
{
get { return _bondSequence * 5; }
}
Run Code Online (Sandbox Code Playgroud) 我试图让WCF双工通信工作正在努力,因为我不断得到"提供给ChannelFactory的InstanceContext包含一个不实现CallbackContractType的UserObject"
我知道有关于这个主题的其他帖子,但无法将它们与我的确切问题联系起来,所以我想发布自己.
继承我的代码.
我只包括我认为相关的位,但如果您需要其他任何内容,请告诉我.
主机接口定义
[ServiceContract(CallbackContract = typeof(IDataCollectorCallback), SessionMode = SessionMode.Required)]
public interface IDataCollector
{
[OperationContract(IsOneWay = true)]
void GetData();
}
public interface IDataCollectorCallback
{
[OperationContract(IsOneWay = true)]
void returnData();
}
Run Code Online (Sandbox Code Playgroud)
实施服务
public class DataCollector : IDataCollector
{
public void GetData()
{
Console.WriteLine("Getting data");
Console.WriteLine("Waiting");
System.Threading.Thread.Sleep(10000);
Console.WriteLine("Sending Data back");
Callback.returnData();
}
IDataCollectorCallback Callback
{
get
{
return OperationContext.Current.GetCallbackChannel<IDataCollectorCallback>();
}
}
}
Run Code Online (Sandbox Code Playgroud)
客户代码.
class Program
{
static void Main(string[] args)
{
// while (true)
//{
Console.WriteLine("Press enter to trigger data collection"); …Run Code Online (Sandbox Code Playgroud) 有一个wcf服务在我的机器上正常运行.
将其移至服务器,现在出现上述错误.
我在服务器上制作了测试证书.
继承人我的客户端配置.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<runtime>
<loadFromRemoteSources enabled="true"/>
</runtime>
<system.serviceModel>
<bindings>
<wsDualHttpBinding>
<binding name="WSDualHttpBinding_IMessageHandlerServer" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" clientBaseAddress="http://192.168.1.74:8081">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" />
<security mode="Message">
<message clientCredentialType="UserName" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsDualHttpBinding>
</bindings>
<client>
<endpoint address="http://192.168.1.100:8080/" binding="wsDualHttpBinding"
bindingConfiguration="WSDualHttpBinding_IMessageHandlerServer"
contract="MessageService.IMessageHandlerServer" name="WSDualHttpBinding_IMessageHandlerServer" behaviorConfiguration="myClientBehavior">
<identity>
<certificate encodedValue="AwAAAAEAAAAUAAAA9fenyF3cSS38ldDDxtUyC8TajBAgAAAAAQAAALgBAAAwggG0MIIBYqADAgECAhD3kPMzVBbXlEAT5S65MldSMAkGBSsOAwIdBQAwFjEUMBIGA1UEAxMLUm9vdCBBZ2VuY3kwHhcNMTEwMjExMTU0MDMwWhcNMzkxMjMxMjM1OTU5WjAXMRUwEwYDVQQDEwxNeVNlcnZlckNlcnQwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAJ9D8W2GBGvwTAZ2eQj12atxPruZxuOwTCLXRwtEvpnoLmlwBuxo7Wb+of0k4XTNLa7q/Xvjh3zsJbvevlPG3hk9+ugds/Je5X69uPbQApYJO2HZNY9hrwfMZ40iaJ54vVAkdnIhDT5pEpmKVFFkPangk1aMyb6Ilm4NjO9bUxjFAgMBAAGjSzBJMEcGA1UdAQRAMD6AEBLkCS0GHR1PAI1hIdwWZGOhGDAWMRQwEgYDVQQDEwtSb290IEFnZW5jeYIQBjdsAKoAZIoRz7jUqlw19DAJBgUrDgMCHQUAA0EAGT7q1aZwAaJ4sMbv53BOo2/yVSpYkTRIaQwT0uYdY1SLyJ7uaUwqJR0jG+nNqwgyOEOfg4Tz0/dX740dw12+1Q==" />
</identity>
</endpoint>
</client>
<behaviors>
<endpointBehaviors>
<behavior name="myClientBehavior">
<clientCredentials>
<serviceCertificate>
<authentication certificateValidationMode="Custom" customCertificateValidatorType="MyX509Validator,MessageHandlerClient" />
</serviceCertificate>
</clientCredentials> …Run Code Online (Sandbox Code Playgroud) 撕裂我的头发试图弄清楚为什么我有这个问题,所以希望有人可以提供帮助.
我有一个使用MEF加载插件的程序.我希望系统的客户端和服务器部分能够使用将位于服务器上的相同插件存储.
我的问题是,当我将插件位置设置为" C:\Users\Administrator\Desktop\ClientPlugins"时插件加载正常.如果我将位置更改为" \\XRP-SERVER\Users\Administrator\Desktop\ClientPlugins",则不会加载插件.
当我\\XRP-SERVER\Users\Administrator\Desktop\ClientPlugins在Windows资源管理器中输入" "时,找到位置并且插件dll就在那里.
请有人帮忙.
如果您需要更多信息,请与我们联系.
根据一个建议我已经尝试编辑配置包括以下但这没有解决问题....
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<runtime>
<loadFromRemoteSources enabled="true"/>
</runtime>
Run Code Online (Sandbox Code Playgroud)
亲切的问候
灰
我知道这已经有很多东西已经尝试了一些东西,但没有运气来修复它.
我有一个C#程序,它构建了一个XML文档,我试图将它保存到MyDocuments中的文件夹.调用XMLDoc.Save函数时,我得到了以下异常.
访问路径'C:\ Users\Ash\Documents\ConfigOutput'被拒绝
我有视觉工作室作为管理员运行.有关如何解决它的任何想法?
我已经尝试保存到桌面和C:\文件夹中.
我正在使用Windows 7.
运行构建的可执行文件似乎也不起作用.
抱歉,我觉得自己很愚蠢.我确实没有在输出路径中添加文件名.我不会删除任何其他人通过这个问题完成的问题!感谢所有的帮助/评论.