Search Results

Search found 52760 results on 2111 pages for 'protobuf net'.

Page 72/2111 | < Previous Page | 68 69 70 71 72 73 74 75 76 77 78 79  | Next Page >

  • Caller Info Attributes in C# 5.0

    - by Jalpesh P. Vadgama
    In c# 5.0 Microsoft has introduced a Caller information attribute. It’s a new feature that is introduced in C# 5.0 and very useful if you want to log your code activities. With the help of this you can implement the log functionality very easily. It can help any programmer in tracing, debugging and diagnostic of any application. With the help of Caller Information we can get following information over there. CallerFilePathAttribute: With help of  this attribute we can get full path of source file that contains caller. This will be file path from which contains caller at compile time. CallerLineNumberAttribute:  With the help of this attribute we can get line number of source file which the method is called. CallerMemberNameAttribute: With the help of this attribute we can get the method or property name of the caller. Read more

    Read the article

  • Generate a Word document from list data

    - by PeterBrunone
    This came up on a discussion list lately, so I threw together some code to meet the need.  In short, a colleague needed to take the results of an InfoPath form survey and give them to the user in Word format.  The form data was already in a list item, so it was a simple matter of using the SharePoint API to get the list item, formatting the data appropriately, and using response headers to make the client machine treat the response as MS Word content.  The following rudimentary code can be run in an ASPX (or an assembly) in the 12 hive.  When you link to the page, send the list name and item ID in the querystring and use them to grab the appropriate data. // Clear the current response headers and set them up to look like a word doc.HttpContext.Current.Response.Clear();HttpContext.Current.Response.Charset ="";HttpContext.Current.Response.ContentType ="application/msword";string strFileName = "ThatWordFileYouWanted"+ ".doc";HttpContext.Current.Response.AddHeader("Content-Disposition", "inline;filename=" + strFileName);// Using the current site, get the List by name and then the Item by ID (from the URL).string myListName = HttpContext.Current.Request.Querystring["listName"];int myID = Convert.ToInt32(HttpContext.Current.Request.Querystring["itemID"]);SPSite oSite = SPContext.Current.Site;SPWeb oWeb = oSite.OpenWeb();SPList oList = oWeb.Lists["MyListName"];SPListItem oListItem = oList.Items.GetItemById(myID);// Build a string with the data -- format it with HTML if you like. StringBuilder strHTMLContent = newStringBuilder();// *// Here's where you pull individual fields out of the list item.// *// Once everything is ready, spit it out to the client machine.HttpContext.Current.Response.Write(strHTMLContent);HttpContext.Current.Response.End();HttpContext.Current.Response.Flush();

    Read the article

  • Storing non-content data in Orchard

    - by Bertrand Le Roy
    A CMS like Orchard is, by definition, designed to store content. What differentiates content from other kinds of data is rather subtle. The way I would describe it is by saying that if you would put each instance of a kind of data on its own web page, if it would make sense to add comments to it, or tags, or ratings, then it is content and you can store it in Orchard using all the convenient composition options that it offers. Otherwise, it probably isn't and you can store it using somewhat simpler means that I will now describe. In one of the modules I wrote, Vandelay.ThemePicker, there is some configuration data for the module. That data is not content by the definition I gave above. Let's look at how this data is stored and queried. The configuration data in question is a set of records, each of which has a number of properties: public class SettingsRecord { public virtual int Id { get; set;} public virtual string RuleType { get; set; } public virtual string Name { get; set; } public virtual string Criterion { get; set; } public virtual string Theme { get; set; } public virtual int Priority { get; set; } public virtual string Zone { get; set; } public virtual string Position { get; set; } } .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } Each property has to be virtual for nHibernate to handle it (it creates derived classed that are instrumented in all kinds of ways). We also have an Id property. The way these records will be stored in the database is described from a migration: public int Create() { SchemaBuilder.CreateTable("SettingsRecord", table => table .Column<int>("Id", column => column.PrimaryKey().Identity()) .Column<string>("RuleType", column => column.NotNull().WithDefault("")) .Column<string>("Name", column => column.NotNull().WithDefault("")) .Column<string>("Criterion", column => column.NotNull().WithDefault("")) .Column<string>("Theme", column => column.NotNull().WithDefault("")) .Column<int>("Priority", column => column.NotNull().WithDefault(10)) .Column<string>("Zone", column => column.NotNull().WithDefault("")) .Column<string>("Position", column => column.NotNull().WithDefault("")) ); return 1; } When we enable the feature, the migration will run, which will create the table in the database. Once we've done that, all we have to do in order to use the data is inject an IRepository<SettingsRecord>, which is what I'm doing from the set of helpers I put under the SettingsService class: private readonly IRepository<SettingsRecord> _repository; private readonly ISignals _signals; private readonly ICacheManager _cacheManager; public SettingsService( IRepository<SettingsRecord> repository, ISignals signals, ICacheManager cacheManager) { _repository = repository; _signals = signals; _cacheManager = cacheManager; } The repository has a Table property, which implements IQueryable<SettingsRecord> (enabling all kind of Linq queries) as well as methods such as Delete and Create. Here's for example how I'm getting all the records in the table: _repository.Table.ToList() And here's how I'm deleting a record: _repository.Delete(_repository.Get(r => r.Id == id)); And here's how I'm creating one: _repository.Create(new SettingsRecord { Name = name, RuleType = ruleType, Criterion = criterion, Theme = theme, Priority = priority, Zone = zone, Position = position }); In summary, you create a record class, a migration, and you're in business and can just manipulate the data through the repository that the framework is exposing. You even get ambient transactions from the work context.

    Read the article

  • Creating a SQL Azure Database Should be Easier

    - by Ken Cox [MVP]
    Every time I try to create a database + tables + data for Windows Azure SQL I get errors.  One of them is 'Filegroup reference and partitioning scheme' is not supported in this version of SQL Server.' It’s partly due to my poor memory (since I’ve succeeded before) and partly due to the failure of tools that should be helping me. For example, when I want to create a script from an existing database on my local workstation, I use SQL Server Management Studio (currently v 11.0.2100.60).  I go to Tasks > Generate Scripts which brings up the nice Generate and Publish Scripts wizard. When I go into the Advanced button, under Script for Server Version, why don’t I see SQL Azure as an option by now? The tool should be sorting this out for me, right? Maybe this is available in SQL Server Data Tools? I haven’t got into that yet. Just merge the functionality with SSMS, please. Anyway, I pick an older version of SQL for the target and still need to tweak it for Azure. For example, I take out all the “[dbo].” stuff. Why is it put there by the wizard? I also have to get rid of "ON [PRIMARY]"  to deal with the error I noted at the top. Yes, there’s information on what a table needs to look like in SQL Azure but the tools should know this so I don’t have to mess with it.

    Read the article

  • Parallel task in C# 4.0

    - by Jalpesh P. Vadgama
    In today’s computing world the world is all about Parallel processing. You have multicore CPU where you have different core doing different work parallel or its doing same task parallel. For example I am having 4-core CPU as follows. So the code that I write should take care of this.C# does provide that kind of facility to write code for multi core CPU with task parallel library. We will explore that in this post. Read More

    Read the article

  • Are you ready to grow that Mo (moustache)? Movember is coming

    - by Chris Hammond
    Well here we are, nearing the end of the month of October and coming up on the month of N Movember once again. We here at DNNCorp are in our third year of supporting the Movember cause, growing facial hair on our upper lips to raise awareness and money for men’s health issues. Anyone can participate in Movember, and if you sign up, join a team, you can order some free materials from the Movember organization that you can use to help try and raise funds. The rules for Movember are simple. Start clean...(read more)

    Read the article

  • Loading Entities Dynamically with Entity Framework

    - by Ricardo Peres
    Sometimes we may be faced with the need to load entities dynamically, that is, knowing their Type and the value(s) for the property(ies) representing the primary key. One way to achieve this is by using the following extension methods for ObjectContext (which can be obtained from a DbContext, of course): 1: public static class ObjectContextExtensions 2: { 3: public static Object Load(this ObjectContext ctx, Type type, params Object [] ids) 4: { 5: Object p = null; 6:  7: EntityType ospaceType = ctx.MetadataWorkspace.GetItems<EntityType>(DataSpace.OSpace).SingleOrDefault(x => x.FullName == type.FullName); 8:  9: List<String> idProperties = ospaceType.KeyMembers.Select(k => k.Name).ToList(); 10:  11: List<EntityKeyMember> members = new List<EntityKeyMember>(); 12:  13: EntitySetBase collection = ctx.MetadataWorkspace.GetEntityContainer(ctx.DefaultContainerName, DataSpace.CSpace).BaseEntitySets.Where(x => x.ElementType.FullName == type.FullName).Single(); 14:  15: for (Int32 i = 0; i < ids.Length; ++i) 16: { 17: members.Add(new EntityKeyMember(idProperties[i], ids[i])); 18: } 19:  20: EntityKey key = new EntityKey(String.Concat(ctx.DefaultContainerName, ".", collection.Name), members); 21:  22: if (ctx.TryGetObjectByKey(key, out p) == true) 23: { 24: return (p); 25: } 26:  27: return (p); 28: } 29:  30: public static T Load<T>(this ObjectContext ctx, params Object[] ids) 31: { 32: return ((T)Load(ctx, typeof(T), ids)); 33: } 34: } This will work with both single-property primary keys or with multiple, but you will have to supply each of the corresponding values in the appropriate order. Hope you find this useful!

    Read the article

  • ASP.NET RedirectPermanent Method using C# and VB.NET

    301 redirection is essential for the best user experience. If something on your website has been changed or moved to a new permanent location, users will need to be permanently redirected. In addition, search engines can follow this type of redirection, and this redirected-to page will now be the one to rank in Google or other search engines, replacing the old page. There are different ways to implement the RedirectPermanent method. This tutorial will illustrate these common techniques with sample VB.NET or C# code. Creating the Sample ASP.NET 4.0 Website RedirectPermanent is new in ASP.NET 4....

    Read the article

  • Enum types, FlagsAttribute & Zero value – Part 2

    - by nmgomes
    In my previous post I wrote about why you should pay attention when using enum value Zero. After reading that post you are probably thinking like Benjamin Roux: Why don’t you start the enum values at 0x1? Well I could, but doing that I lose the ability to have Sync and Async mutually exclusive by design. Take a look at the following enum types: [Flags] public enum OperationMode1 { Async = 0x1, Sync = 0x2, Parent = 0x4 } [Flags] public enum OperationMode2 { Async = 0x0, Sync = 0x1, Parent = 0x2 } To achieve mutually exclusion between Sync and Async values using OperationMode1 you would have to operate both values: protected void CheckMainOperarionMode(OperationMode1 mode) { switch (mode) { case (OperationMode1.Async | OperationMode1.Sync | OperationMode1.Parent): case (OperationMode1.Async | OperationMode1.Sync): throw new InvalidOperationException("Cannot be Sync and Async simultaneous"); break; case (OperationMode1.Async | OperationMode1.Parent): case (OperationMode1.Async): break; case (OperationMode1.Sync | OperationMode1.Parent): case (OperationMode1.Sync): break; default: throw new InvalidOperationException("No default mode specified"); } } but this is a by design constraint in OperationMode2. Why? Simply because 0x0 is the neutral element for the bitwise OR operation. Knowing this singularity, replacing and simplifying the previous method, you get: protected void CheckMainOperarionMode(OperationMode2 mode) { switch (mode) { case (OperationMode2.Sync | OperationMode2.Parent): case (OperationMode2.Sync): break; case (OperationMode2.Parent): default: break; } This means that: if both Sync and Async values are specified Sync value always win (Zero is the neutral element for bitwise OR operation) if no Sync value specified, the Async method is used. Here is the final method implementation: protected void CheckMainOperarionMode(OperationMode2 mode) { if (mode & OperationMode2.Sync == OperationMode2.Sync) { } else { } } All content above prove that Async value (0x0) is useless from the arithmetic perspective, but, without it we lose readability. The following IF statements are logically equals but the first is definitely more readable: if (OperationMode2.Async | OperationMode2.Parent) { } if (OperationMode2.Parent) { } Here’s another example where you can see the benefits of 0x0 value, the default value can be used explicitly. <my:Control runat="server" Mode="Async,Parent"> <my:Control runat="server" Mode="Parent">

    Read the article

  • Reading RSS data with Linq to Xml

    - by hakanbilge
     Linq to Xml is the best method, I think, for querying, constructing and writing Xml data. In this article, I'll show how to read Rss data with this powerful Xml technique, Linq. Now, create a Website in Visual Studio, add a Textbox and a  [read more....]

    Read the article

  • MammothVPS launches Backups, DNS Management and more!!!

    - by stefan.sedich
    Yesterday we launched a bunch of new features over at MammothVPS, - All VPS' now have an on-site, off-server backup facility available to them. By default all customers will have 1 free weekly backup made available to them, and should you wish to you can purchase more slots which are available in daily, weekly and monthly schedules. - DNS hosting has been made available and will be free for all customers. You can find the new interface in your mPanel. - A cleanup of the menu system has been done to make it easier to navigate around both the site and mPanel. - You will find new sections on site, we now have more information about our services and have included things like a Knowledge Base, which will provide information on howto setup various applications on your VPS. - Added the ability to change the kernel your VPS is running on. So head on over to MammothVPS and check it out.

    Read the article

  • How much should I rely on Visual Studio's Auto Generated Code?

    - by Ant
    So I'm reading up on ASP.NET with VB.NET and I want to start making my own, professionally built website using ASP. I'm wondering though; I'm still using the basics so I'm really just a novice, but how much should I rely on Visual Studio to create my elements? Should I make my own text boxes and have my own login routine, or should I just use ASP's login features? I know eventually you have to use your own classes and such which is where the real coding comes in, but I'm not sure how relaible, flexible and secure the pre-wrote elements are? Any help would be greatly appreciated.

    Read the article

  • Retrieve data from an ASP.Net application using Ado.Net 2.0 disconnected model

    - by nikolaosk
    This is the second post in a series of posts regarding to ADO.Net 2.0. Have a look at the first post if you like. In this post I am going to investigate the "Disconnected" model. When I say "Disconnected" I mean Datasets . Datasets are in memory representations of tables in a particular database. A Dataset contains a Table collection and each Table collection contains a Row collection and each Row collection contains a Columns collection. So initially you connect to the database, get the data to...(read more)

    Read the article

  • OpenXML error “file is corrupt and cannot be opened.”

    - by nmgomes
    From time to time I ear some people saying their new web application supports data export to Excel format. So far so good … but they don’t tell the all story … in fact almost all the times what is happening is they are exporting data to a Comma-Separated file or simply exporting GridView rendered HTML to an xls file. Ok … it works but it’s not something I would be proud of. So … yesterday I decided to take a look at the Office Open XML File Formats Specification (Microsoft Office 2007+ format) based on well-known technologies: ZIP and XML. I start by installing Open XML SDK 2.0 for Microsoft Office and playing with some samples. Then I decided to try it on a more complex web application and the “file is corrupt and cannot be opened.” message start happening. Google show us that many people suffer from the same and it seems there are many reasons that can trigger this message. Some are related to the process itself, others with encodings or even styling. Well, none solved my problem and I had to dig … well not that much, I simply change the output file extension to zip and extract the zip content. Then I did the same to the output file from my first sample, compare both zip contents with SourceGear DiffMerge and found that my problem was Culture related. Yes, my complex application sets the Thread.CurrentThread.CurrentCulture  to a non-English culture. For sample purposes I was simply using the ToString method to convert numbers and dates to a string representation but forgot that XML is culture invariant and thus using a decimal separator other than “.” will result in a deserialization problem. I solve the “file is corrupt and cannot be opened.” by using Convert.ToString(object, CultureInfo.InvariantCulture) method instead of the ToString method. Hope this can help someone.

    Read the article

  • Retrieve data from an ASP.Net application using ADO.Net 2.0 connected model

    - by nikolaosk
    I have been teaching Entity Framework,LINQ to SQL,LINQ to objects,LINQ to XML for some time now. I am huge fan of LINQ to Entities and I am using Entity Framework as my main data access technology. Entity framework is in the second version right now and I can accomplish most of the things I need. I am sure the guys in the ADO.Net team will implement many more features in the future. I am a strong believer that you cannot really understand the benefits of LINQ to SQL or LINQ to Entities unless you...(read more)

    Read the article

  • AjaxControlToolkit.resources.dll files deleted

    - by Steve
    I'm using the ASP.NET Ajax toolkit. In addition to the AjaxControlToolkit.dll in my bin directory, I have language directories named es, de, fr, etc... The single file, the AjaxControlToolkit.resources.dll disappears from these directories every once in a while - I can't figure out why. I manually copy them back, but I've purposely done rebuild and clean solutions and they are still there. Somewhere during my normal course of work, when I'm not looking, they're gone. Any clues?

    Read the article

  • Gridview inside a ModalPopUpExtender causes ModalPopUpExtender to close

    - by harold-sota
    I have a gridview inside a ModalPopUpExtender, the grid view have the button add delete and edit when i clic one of the button of the gridview the popup is closed. I wont to close the popup when the close button is clicked. This is the asp.net part: < cc1: ModalPopupExtender ID="NamePopup" runat="server" PopupControlID="OptionPanel" TargetControlID="btnD" BackgroundCssClass="mpBg" DropShadow="true" OkControlID="btnSavePopup" CancelControlID="btnPostCancel" < / cc1:ModalPopupExtender Any ideas??

    Read the article

  • Using Server.CreateObject("ADODB.Stream") in IE7

    - by Daud
    I have a asp.net 1.1 application that uses the following code to write out a file in the response: Dim objStream As Object objStream = Server.CreateObject("ADODB.Stream") objStream.open() objStream.type = 1 objStream.loadfromfile(localfile) Response.BinaryWrite(objStream.read) This code is called by a pop up window that displays this file or gives a open/save dialog in Internet explorer. The problem is, that it seems to work fine in IE6 but in IE7 the pop up opens and then closes without displaying the file. Any one know whats wrong?

    Read the article

  • How can I know which Area my MVC controller action is being called in?

    - by kripto_ash
    I want to know how, from a controller action, I could identify the area in which the controller is in via the MVC framework (I mean, without making all controllers in a given area inherit from a base controller with that info). I'm particularly interested in the case of child actions (controller actions rendered via RenderAction), the area of the calling parent controller for instance. I'm using ASP .NET MVC 2.0 RTM

    Read the article

  • Application framework building

    - by Muhammad Umar Siddique
    Hi I was looking to build a Data Access Layer for my new web based application, I'm using ASP.NET. I'm want to build a framework not only for this application but also want to utilize it for my future projects. Actually my main aim is to make a framework, from DAC, DAL, BL to GUI. I want suggestions from you guys that what should i adopt, what give me flexibility, which suits for both small and large size applications. Thanks in advance.

    Read the article

  • Pass values from MasterPage UserControl to child ASPX Page

    - by Leekey
    Hi, Senario: Masterpage with a UserControl and a child ASPX page In the past when using this senario I've used an Interface as a way to pass a value from the UserControl (embedded in a master page) to the masterpage code behind then consume that value in the child aspx page. My question is now that asp.net 4 have arrived is this still a good way to achieve this or is there another or perhaps better way to do it? I've read somewhere that perhaps "delegates" is perhaps another route to take. Any help much appreciated Lk

    Read the article

  • Calling Web Services Asynchronously in Page_Load Event

    - by Umar Siddique
    I'm working on a web application using VB.NET. In page load event am calling a remote web service which take time to bring the data. During this process none of the other contents on page are shown(render). I want to call this remote web service asynchronously so that other data of page is displayed and web service data will be displayed when its available.

    Read the article

< Previous Page | 68 69 70 71 72 73 74 75 76 77 78 79  | Next Page >