c#-3.0

To check wether a specific project reference exists (C# Code, Preprocessor Directives …)

丶灬走出姿态 提交于 2019-12-23 17:26:12
问题 i'm fairly new to C# / .NET so I hope there is a solution for my problem. I'm working with 2 different image-processing libraries which have their own classes to represent images. Because I don't want to use this classes in my own (private) class library, I want to implement my own "myImage"-Class which is supposed to be a wrapper around both of the other classes. (I have of course to add the functionality of the libraries if they are missing). My problem is basically now like this: The

Should any domain object, not be serializable?

情到浓时终转凉″ 提交于 2019-12-23 16:45:51
问题 Is there a way to just tell the compiler, that I want my objects to be serializable by default? 回答1: Pretty much every serialization engine is going to want to know that your objects are suitable. This can take the form of: [Serializable] / ISerializable ( BinaryFormatter , SoapFormatter ) [Serializable] / IXmlSerializable (and public ) ( XmlSerializer ) [DataContract] / [MessageContract] (or most of the above) ( DataContractSerializer and variants) AFAIK, there is no way of avoiding this

Visual Studio not supporting XSLT 2.0

拜拜、爱过 提交于 2019-12-23 16:33:10
问题 i am using visual studio 2010 . when running xslt2.0 in that getting below errors xsl:value-of/* ** is not yet implemented. 'xsl:result-document'** is not yet implemented. can any one help me to reslove the above issues 回答1: If you want to use XSLT 2.0 you need to switch from XslCompiledTransform to an XSLT 2.0 processor like the .NET version of Saxon 9 or like AltovaXML or like XmlPrime. Microsoft's XslCompiledTransform is an XSLT 1.0 processor, even in .NET 4.5/VS 2012. However the named

Visual Studio not supporting XSLT 2.0

老子叫甜甜 提交于 2019-12-23 16:32:40
问题 i am using visual studio 2010 . when running xslt2.0 in that getting below errors xsl:value-of/* ** is not yet implemented. 'xsl:result-document'** is not yet implemented. can any one help me to reslove the above issues 回答1: If you want to use XSLT 2.0 you need to switch from XslCompiledTransform to an XSLT 2.0 processor like the .NET version of Saxon 9 or like AltovaXML or like XmlPrime. Microsoft's XslCompiledTransform is an XSLT 1.0 processor, even in .NET 4.5/VS 2012. However the named

Should empty “if” statement in C# lead to an error or warning?

这一生的挚爱 提交于 2019-12-23 12:27:14
问题 Let me start from a real life example: Customer: Alex, just noticed something strange in the RemovalProcessor at line 138: if (Session.Handler.ExecutePrefetchTasks()==null); Session.ExecuteDelayedQueries(); Should the semicolumn behind the 'if' be there? Me: Oops... I'll send this to our guys to check, but most likely, you're right. Although the case is rare, I admit nearly any big project has similar issue. I understand that semicolon (and statement block) usage rules in C# can't be changed

How to properly unit test calling UI method on another thread?

感情迁移 提交于 2019-12-23 10:57:10
问题 Having coded an extension method (based on GUI update when starting event handler class on separate thread?): public static class ControlExtensions { public static TResult InvokeEx<TControl, TResult> (this TControl control, Func<TControl, TResult> func) where TControl : Control { if (control.InvokeRequired) return (TResult)control.Invoke (func, control); return func (control); } } I've been trying to unit test this method both from a UI thread and a normal thread and I can't seem to be able

IronRuby performance issue while using Variables

瘦欲@ 提交于 2019-12-23 04:09:19
问题 Here is code of very simple expression evaluator using IronRuby public class BasicRubyExpressionEvaluator { ScriptEngine engine; ScriptScope scope; public Exception LastException { get; set; } private static readonly Dictionary<string, ScriptSource> parserCache = new Dictionary<string, ScriptSource>(); public BasicRubyExpressionEvaluator() { engine = Ruby.CreateEngine(); scope = engine.CreateScope(); } public object Evaluate(string expression, DataRow context) { ScriptSource source;

Failed network error while downloading the files from Google Chrome

ⅰ亾dé卋堺 提交于 2019-12-23 03:00:51
问题 I written the below c# code for downloading the attachments in my application, when i run the code i can download the files using Mozilla, internet explorer but this is not working in Google Chrome. string base64FileString = result; byte[] binaryFile = Convert.FromBase64String(base64FileString); Response.ContentType = "application/octet-stream"; Response.AddHeader("content-disposition", String.Format("attachment; filename=\"{0}\"", Request.QueryString["FILENAME"])); Response.Clear(); Response

TextTransform.exe seems to only accept an older version of C#

旧城冷巷雨未停 提交于 2019-12-22 13:53:15
问题 When I expand T4 templates inside Visual Studio, I can use the full C# 3.0 syntax, including LINQ expressions, etc. When I expand it outside Visual Studio using TextTransform.exe it complains about LINQ expressions and other new features of C# 3.0. Is there a newer version of TextTransform.exe? The one I'm running is in: C:\Program Files\Common Files\Microsoft Shared\TextTemplating\1.2\TextTransform.exe 回答1: 1.2 is the version of TextTransform that shipped with Visual Studio 2008. However, it

How to stop the execution of a method after a specific time?

情到浓时终转凉″ 提交于 2019-12-22 09:15:15
问题 I need to stop the execution of a method if it has not completed within a limited period of time. To do this work I can use the Thread.Abort method in this way: void RunWithTimeout(ThreadStart entryPoint, int timeout) { var thread = new Thread(() => { try { entryPoint(); } catch (ThreadAbortException) { } }) { IsBackground = true }; thread.Start(); if (!thread.Join(timeout)) thread.Abort(); } Given that I'm using .NET 3.5, is there a better way? Edit: following the comments here my entryPoint