Search Results

Search found 1919 results on 77 pages for 'typeof'.

Page 41/77 | < Previous Page | 37 38 39 40 41 42 43 44 45 46 47 48  | Next Page >

  • How do you mark class with TypeConverter that is not in referenced solution?

    - by Greg McGuffey
    I have a class that I've written a TypeConverter for. I want to keep the TypeConverter separate from the main solution, as it is only needed at design time and have an extensibility project now that contains the TypeConverter. Thus, when I deploy, I don't need to deploy the extensibility assembly at all. However, I can't figure out the appropriate string to use in the attribute to actually connect the class to the converter. Note I can't use this: [TypeConverter(typeof(MyConverter)] because MyConverter is in a project that isn't referenced. I need to use the string overload, but can't figure out what to use: [TypeConverter("what the heck goes in here!")] I think I need maybe a path to the assembly, maybe a GUID, the class name...just not sure...

    Read the article

  • WCF: How to detect new connections to WCF PerSession services ?

    - by Christian Toma
    I have a self-hosted WCF service with the InstanceContextMode set to PerSession. How can I detect new client connections (sessions) to my service from the host application and use that new session context to observe my service trough its events? Something like: [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)] public class MyService : IMyService { public event EventHandler ClientRegistered; public event EventHandler FileUploaded; } and from my host application to be able to do: ServiceHost svc = new ServiceHost(typeof(MyService)); svc.Open(); // something like: svc.NewSession += new EventHandler(...) //... public void SessionHandler(InstanceContext SessionContext) { MySessionHandler NewSessionHandler = new MySessionHandler(SessionContext); // From MySessionHandler I handle the service's events (FileUploaded, ClientRegistered) // for this session and notify the UI of any changes. NewSessionHandler.Handle(); }

    Read the article

  • NHibernate CreateSQLQuery data conversion from bit to boolean error

    - by RemotecUk
    Hi, Im being a bit lazy in NHibernate and using Session.CreateSqlQuery(...) instead of doing the whole thing with Lambda's. Anyway what struct me is that there seems to be a problem converting some of the types returned from (in this case the MySQL) DB into native .Net tyes. The query in question looks like this.... IList<Client> allocatableClients = Session.CreateSQLQuery( "select clients.id as Id, clients.name as Name, clients.customercode as CustomerCode, clients.superclient as SuperClient, clients.clienttypeid as ClientType " + ... ... .SetResultTransformer(new NHibernate.Transform.AliasToBeanResultTransformer(typeof(Client))).List<Client>(); The type in the database of SuperClient is a bit(1) and in the Client object the type is a bool. The error received is: System.ArgumentException: Object of type 'System.UInt64' cannot be converted to type 'System.Boolean'. It seems strange that this conversion cannot be completed. Would be greatful for any ideas. Thanks.

    Read the article

  • Cast to generic type in C#

    - by Andrej
    I have a Dictionary to map a certain type to a certain generic object for that type. For example: typeof(LoginMessage) maps to MessageProcessor<LoginMessage> Now the problem is to retrieve this generic object at runtime from the Dictionary. Or to be more specific: To cast the retrieved object to the specific generic type. I need it to work something like this: Type key = message.GetType(); MessageProcessor<key> processor = messageProcessors[key] as MessageProcessor<key>; Hope there is a easy solution to this. Edit: I do not want to use Ifs and switches. Due to performance issues I cannot use reflection of some sort either.

    Read the article

  • Implementing IPermission

    - by joniba
    Hi there, I'm considering writing a custom IPermission implementation but am not clear as to how it should work. I've already implemented IPrincipal and IIdentity. What I would like to accomplish is to be able to check permissions vis a vis the current IPrincipal's authorizations rather than its roles. Generally, authorizations are read/add-delete/update/none for a given type. So I would like to write something like this: [CustomPermission(SecurityAction.Demand, Type = typeof(Foo), MinimumAuthorization = AuthorizationFlags.Read)] public void SomeMethod(){} Is this possible? I've looked over the code at http://msdn.microsoft.com/en-us/library/system.security.ipermission.aspx. This shows how to implement the interface, but I don't understand how the above pseudo-code would be able to check against the IPrincipal's authorizations for the type. Any help or resource references would be appreciated. Joni

    Read the article

  • WCF Integration Facility and Self-Hosted Services

    - by IanT8
    I'm self-hosting several services where I do this to register the service: host = new ServiceHost(typeof(MyService)); host.Open(); Behind the scenes, wcf instantiates my service via the default constructor. Is it possble to use the WCF Integration Facility of Castle Windsor to get WCF to call on Windsor to create the service when I am self-hosting? The example seems shows IIS hosted services where the 1st line of the MyService.svc file looks like: <%@ServiceHost language=c# Debug="true" Service="Microsoft.ServiceModel.Samples.CalculatorService" Factory=WindsorServiceHostFactory%> where presumably a factory is used by wcf to instantiate the service instance.

    Read the article

  • [.NET] How to load multiple mscorlib.dll and call their inner functions seperately?

    - by Sean
    Dears, This is for research purpose. I have .Net framework 2.0 installed, and I want to load mscorlib.dll 1.1 dynamiclly to execute its specific inner function. When I wrote this code in C#: static void Main(string[] args) { Assembly assem = Assembly.LoadFrom("C:\\mscorlib_my_private_1.1.dll"); System.Type type = assem.GetType("System.Console"); Type[] typeArray =new Type[1]; typeArray.SetValue(typeof(string),0); System.Reflection.MethodInfo info = type.GetMethod("WriteLine", typeArray); object[] param = new object[1]; param[0] = assem.FullName; type.InvokeMember("WriteLine", System.Reflection.BindingFlags.InvokeMethod, System.Type.DefaultBinder, "", param); } The output is "mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Not the expected 1.1 version. After Googling a lot, I know that mscorlib.dll is very special, but is it impossible? Cheers~ Sean

    Read the article

  • How to change default image of derived ToolStripButton?

    - by Special Touch
    It seems like a simple task. Create a C# class that derives from ToolStripButton. The derived ToolStripButton should behave exactly the same as the parent class in the designer and the application, except that the default image should be different. Surprisingly just changing the constructor is not sufficient: public CustomToolStripButton() { base.Image = (Image) new Bitmap(typeof(CustomToolStripButton), "CustomImage.bmp"); } When the ToolStripButton is displayed in the designer, the original default image is shown. There must be a simple solution. What could it be?

    Read the article

  • Nullable Enum nullable type question

    - by Michael Kniskern
    I get the following compilation error with the following source code: Compilation Error: Type of conditional expression cannot be determined because there is no implicit conversion between '' and 'MyEnum' Source Code public enum MyEnum { Value1, Value2, Value3 } public class MyClass { public MyClass() {} public MyEnum? MyClassEnum { get; set; } } public class Main() { object x = new object(); MyClass mc = new MyClass() { MyClassEnum = Convert.IsDBNull(x) : null ? (MyEnum) Enum.Parse(typeof(MyEnum), x.ToString(), true) }; } How can I resolve this error?

    Read the article

  • WCF on Windows 7 not working

    - by Nyla Pareska
    I am using an example from iDesign about one way calls. I can get it to work on a Vista machine (VS2008) but not on a windows 7 machine (VS2010). I get this error: HTTP could not register URL http://+:8001/MyService/. Your process does not have access rights to this namespace ServiceHost host = new ServiceHost(typeof(MyService)); host.Open(); I get the error on the host.Open(); line. I noticed that windows asks first for some firewall and to give permission which I did but still it is not working. What can I do?

    Read the article

  • ASP.NET MVC ViewModelBuilder Suggestions

    - by Marco
    For anything but trival view models, I use a view model builder that handles the responsibility of generating the view model object. Right now, I use constructor injection of the builders into my controllers but this smells a little since the builder is really dependent upon which action method is being executed. I have two ideas in mind. The first one would involve a custom ActioFilter allowing me to decorate each action method with the appropriate builder to use. The second would be to add an override of the View method that is open to accepting a generic. This is what my code currently looks like. Note, the builder get injected via the ctor. [HttpGet, ImportModelStateFromTempData, Compress] public ActionResult MyAccount() { return View(accountBuilder.Build()); } Here is what option one would look like: [HttpGet, ImportModelStateFromTempData, Compress, ViewModelBuilder(typeof(IMyAccountViewModelBuilder)] public ActionResult MyAccount() { return View(accountBuilder.Build()); } Or option two: [HttpGet, ImportModelStateFromTempData, Compress] public ActionResult MyAccount() { return View<IMyAccountViewModelBuilder>(); } Any thoughts or suggestions would be great!

    Read the article

  • Random value from Flags enum

    - by Chris Porter
    Say I have a function that accepts an enum decorated with the Flags attribute. If the value of the enum is a combination of more than one of the enum elements how can I extract one of those elements at random? I have the following but it seems there must be a better way. [Flags] enum Colours { Blue = 1, Red = 2, Green = 4 } public static void Main() { var options = Colours.Blue | Colours.Red | Colours.Green; var opts = options.ToString().Split(','); var rand = new Random(); var selected = opts[rand.Next(opts.Length)].Trim(); var myEnum = Enum.Parse(typeof(Colours), selected); Console.WriteLine(myEnum); Console.ReadLine(); }

    Read the article

  • WPF Two Commands handlers, One Command

    - by Aran Mulholland
    Im deriving from a third party control. It is implementing ApplicationCommands.SelectAll. However the behaviour i want is slightly different. there is no virtual method i can override, and when i register a class handler, like so CommandManager.RegisterClassCommandBinding(typeof(MyDerivedControl), new CommandBinding(ApplicationCommands.SelectAll, new ExecutedRoutedEventHandler(OnExecutedSelectAll), new CanExecuteRoutedEventHandler(OnCanExecuteSelectAll))); My methods do not get called. The third party control i am deriving from is marking e.Handled=true; in its command handlers ( i know this cause i have seen the source, but i cant modify it ) What can i do?

    Read the article

  • LinkedList cannot be serialised?

    - by iTayb
    Here are my classes: http://pastebin.com/3dc5Vb1t When I try to run BookStore b = new BookStore(); b.LoadFromXML(Server.MapPath("list.xml")); Label1.Text = b.ToString(); I get the following error: You must implement a default accessor on System.Collections.Generic.LinkedList`1[[Book, App_Code.cxsacizw, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]] because it inherits from ICollection. The error source is XmlSerializer s = new XmlSerializer(typeof(BookStore)); When I tried to look for a solution on google, I found it that LinkedList has some problems with serialization. How can I deal with it? Thank you very much.

    Read the article

  • NHibernate ICriteria with a bag

    - by plunk
    Hi, Just a quick question. If I've got 2 tables that are joined in a 3rd table with a many-to-many relationship, is it possible to write an ICriteria with expressions in one of the tables and the join table? Lets say the mapping file looks something like: <bag name ="Bag" table="JoinTable" cascade ="none"> <key column="Data_ID"/> <many-to-many class="Data2" column="Data2_ID"/> </bag> Is it then possible to write an ICriteria like the following? ICriteria crit = session.CreateCriteria(typeof(Data)); crit.Add(Expression.Eq("Name", name)); crit.Add(Expression.Between("Date", startDate, endDate)); crit.Add(Expression.Eq("Bag", data2IDNumber)); When I try this, it tells me I the expected type is IList, whereas the actual type is Bag. Thanks.

    Read the article

  • Javascript Regex to convert dot notation to bracket notation

    - by Tauren
    Consider this javascript: var joe = { name: "Joe Smith", location: { city: "Los Angeles", state: "California" } } var string = "{name} is currently in {location.city}, {location.state}"; var out = string.replace(/{([\w\.]+)}/g, function(wholematch,firstmatch) { return typeof values[firstmatch] !== 'undefined' ? values[firstmatch] : wholematch; }); This will output the following: Joe Smith is currently in {location.city}, {location.state} But I want to output the following: Joe Smith is currently in Los Angeles, California I'm looking for a good way to convert multiple levels of dot notation found between braces in the string into multiple parameters to be used with bracket notation, like this: values[first][second][third][etc] Essentially, for this example, I'm trying to figure out what regex string and function I would need to end up with the equivalent of: out = values[name] + " is currently in " + values["location"]["city"] + values["location"]["state"];

    Read the article

  • Confirm box before closing a tab

    - by piemesons
    I want to have a confirm box when user tries to close the window. window.onbeforeunload = function (evt) { var message = 'Are you sure you want to leave, cause there are some unsaved changes?'; if (typeof evt == 'undefined') { evt = window.event; } if (evt ) { evt.returnValue = message; } return message; } The thing is i want to check a variables value var sncro=1; If its value is not equal to one then this confirmation box should be there..else no need to have a confirmation. I m not able to figure this..Its soo silly but i request anybody can have a look on the code. thnks.

    Read the article

  • Custom Designers deserialize SplitContainer problem

    - by Hamid
    Hi I just using this link http://msdn.microsoft.com/en-us/magazine/cc163634.aspx for extent custom designer. I using BasicDesignerLoader type because need xml data for save in db. all thing work properly. I try add SplitContainer to form and then serialize form, it's ok, but when try deserialize it, items that contains in SplitContainer Panel, failed. after i check it see not implement ReadRefrence method (only wrote WriteReference method) How to implement it fast ? Note: After download sample from http://download.microsoft.com/download/f/2/7/f279e71e-efb0-4155-873d-5554a0608523/DesignerHosting.exe, you must add typeof(System.Windows.Forms.SplitContainer) to ToolboxXmlManager.cs(Line 13) in ToolBox project. Note2: Find (De)Serialize method in BasicHostLoader.cs at Loader Project Thanks in advanced

    Read the article

  • How to include multiple XML files in a single XML file for deserialization by XmlSerializer in .NET

    - by harrydev
    Hi, is it possible to use the XmlSerializer in .NET to load an XML file which includes other XML files? And how? This, in order to share XML state easily in two "parent" XML files, e.g. AB and BC in below. Example: using System; using System.IO; using System.Xml.Serialization; namespace XmlSerializerMultipleFilesTest { [Serializable] public class A { public int Value { get; set; } } [Serializable] public class B { public double Value { get; set; } } [Serializable] public class C { public string Value { get; set; } } [Serializable] public class AB { public A A { get; set; } public B B { get; set; } } [Serializable] public class BC { public B B { get; set; } public C C { get; set; } } class Program { public static void Serialize<T>(T data, string filePath) { using (var writer = new StreamWriter(filePath)) { var xmlSerializer = new XmlSerializer(typeof(T)); xmlSerializer.Serialize(writer, data); } } public static T Deserialize<T>(string filePath) { using (var reader = new StreamReader(filePath)) { var xmlSerializer = new XmlSerializer(typeof(T)); return (T)xmlSerializer.Deserialize(reader); } } static void Main(string[] args) { const string fileNameA = @"A.xml"; const string fileNameB = @"B.xml"; const string fileNameC = @"C.xml"; const string fileNameAB = @"AB.xml"; const string fileNameBC = @"BC.xml"; var a = new A(){ Value = 42 }; var b = new B(){ Value = Math.PI }; var c = new C(){ Value = "Something rotten" }; Serialize(a, fileNameA); Serialize(b, fileNameB); Serialize(c, fileNameC); // How can AB and BC be deserialized from single // files which include two of the A, B or C files. // Using ideally something like: var ab = Deserialize<AB>(fileNameAB); var bc = Deserialize<BC>(fileNameBC); // That is, so that A, B, C xml file // contents are shared across these two } } } Thus, the A, B, C files contain the following: A.xml: <?xml version="1.0" encoding="utf-8"?> <A xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Value>42</Value> </A> B.xml: <?xml version="1.0" encoding="utf-8"?> <B xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Value>3.1415926535897931</Value> </B> C.xml: <?xml version="1.0" encoding="utf-8"?> <C xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Value>Something rotten</Value> </C> And then the "parent" XML files would contain a XML include file of some sort (I have not been able to find anything like this), such as: AB.xml: <?xml version="1.0" encoding="utf-8"?> <AB xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <A include="A.xml"/> <B include="B.xml"/> </AB> BC.xml: <?xml version="1.0" encoding="utf-8"?> <BC xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <B include="B.xml"/> <C include="C.xml"/> </BC> Of course, I guess this can be solved by implementing IXmlSerializer for AB and BC, but I was hoping there was an easier solution or a generic solution with which classes themselves only need the [Serializable] attribute and nothing else. That is, the split into multiple files is XML only and handled by XmlSerializer itself or a custom generic serializer on top of this. I know this should be somewhat possible with app.config (as in http://stackoverflow.com/questions/480538/use-xml-includes-or-config-references-in-app-config-to-include-other-config-files), but I would prefer a solution based on XmlSerializer. Thanks.

    Read the article

  • To call SelectMany dynamically in the way of System.Linq.Dynamic

    - by user341127
    In System.Linq.Dynamic, there are a few methods to form Select, Where and other Linq statements dynamically. But there is no for SelectMany. The method for Select is as the following: public static IQueryable Select(this IQueryable source, string selector, params object[] values) { if (source == null) throw new ArgumentNullException("source"); if (selector == null) throw new ArgumentNullException("selector"); LambdaExpression lambda = DynamicExpression.ParseLambda(source.ElementType, null, selector, values); IQueryable result = source.Provider.CreateQuery( Expression.Call( typeof(Queryable), "Select", new Type[] { source.ElementType, lambda.Body.Type }, source.Expression, Expression.Quote(lambda))); return result; } I tried to modify the above code, after hours working, I couldn't find a way out. Any suggestions are welcome. Ying

    Read the article

  • Render a user control ascx

    - by Jeremy
    I want to use an ascx as a template, and render it programatically, using the resulting html as the return value of an ajax method. Page pageHolder = new Page(); MyUserControl ctlRender = (MyUserControl)pageHolder.LoadControl(typeof(MyUserControl),null); pageHolder.Controls.Add(ctlRender); System.IO.StringWriter swOutput = new System.IO.StringWriter(); HttpContext.Current.Server.Execute(pageHolder, swOutput, false); return swOutput.ToString(); This all executes, and the Page Load event of the user control fires, but the StringWriter is always empty. I've seen similar code to this in other examples, what am I missing?

    Read the article

  • How do you tell if your migrations are up to date with migratordotnet?

    - by Lance Fisher
    I'm using migratordotnet to manage my database migrations. I'm running them on application setup like this, but I would also like to check on application startup that the migrations are up to date, and provide the option to migrate to latest. How do I tell if there are available migrations that need to be applied? I see that I can get the migrations that were applied like this var asm = Assembly.GetAssembly(typeof(Migration_0001)); var migrator = new Migrator.Migrator("SqlServer", setupInfo.DatabaseConnectionString, asm); var applied = migrator.AppliedMigrations; I like to do something like this: var available = migrator.AvailableMigrations; //this property does not exist.

    Read the article

  • Dynamically Added CheckBox Column is Disabled in GridView

    - by Mark Maslar
    I'm dynamically adding a Boolean column to a DataSet. The DataSet's table is the DataSource for a GridView, which AutoGenerates the columns. Issue: The checkboxes for this dynamically generated column are all disabled. How can I enable them? ds.Tables["Transactions"].Columns.Add("Retry", typeof(System.Boolean)); ds.Tables["Transactions"].Columns["Retry"].ReadOnly = false; In other words, how can I control how GridView generates the CheckBoxes for a Boolean field? (And why does setting ReadOnly to False have no effect?) Thanks!

    Read the article

  • Microsoft.Biztalk.explorerom.dll reference in asp.net application resulting system.nullreferenceexce

    - by sheetal.oza
    Hi, I have a asp.net application in order to start/stop applications and ports of Biztalk server 2006 r2. I have used "Microsoft.Biztalk.explorerom.dll (C:/Program Files/Biztalk Server 2006/Developer tool) " to achieve this. This is working fine on development machine since biz talk server is installed on local machine. But in the production environment (asp.net web server ,windows 2003 and iis 6.0)...this give System.nullreferenceexception (object reference not set..) at BtsCatalogExplorer explorer = (BtsCatalogExplorer)myGroup.CreateInstance(typeof(BtsCatalogExplorer)) my biztalk server and sql server are on two different box. In my setup (asp.net web application)..adding Microsoft.Biztalk.explorerom.dll and Microsoft.Biztalk.Applicationdeployment.engine.dll to GAC. But still no luck. Do i need to install biz talk server on my local machine even though I am connecting to different biz talk server?? And help is appreciated...

    Read the article

  • Could the UIHint attribute accept a property of the current class ?

    - by user252160
    I found the follwing code in MSDN . How can I change this "UnitsInStock" with a value that my Product class has. For instance, Product has a FieldType property which has a string property called Name. I'd like to use that FieldType.Name property instead of hardcoding with a string. However, I cannot specify "this", or the current instance as an argument of the UIHint attribute . Please, help using System; using System.Web.DynamicData; using System.ComponentModel.DataAnnotations; [MetadataType(typeof(ProductMetadata))] public partial class Product { } public partial class ProductMetadata { [UIHint("UnitsInStock")] [Range(100, 10000, ErrorMessage = "Units in stock should be between {1} and {2}.")] public object UnitsInStock; }

    Read the article

< Previous Page | 37 38 39 40 41 42 43 44 45 46 47 48  | Next Page >