Search Results

Search found 46 results on 2 pages for 'mainma'.

Page 2/2 | < Previous Page | 1 2 

  • Export to Excel from ASP.NET produces files unreadable with Excel Viewer

    - by MainMa
    Hi, I want to output some dynamic data from an ASP.NET website to Excel. I found that the easiest way which does not require to use Excel XML or to install Excel on server machine is to output data as a table and specify application/vnd.ms-excel type. The problem is when I do so and try to open the file in Excel Viewer, I receive the following error message: Microsoft Excel Viewer cannot open files of this type. Then nothing is opened. Even an easiest code such as: protected void Page_Load(object sender, EventArgs e) { Response.Clear(); Response.Buffer = true; HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=Example.xls"); Response.ContentType = "application/vnd.ms-excel"; StringWriter stringWriter = new System.IO.StringWriter(); HtmlTextWriter htmlTextWriter = new System.Web.UI.HtmlTextWriter(stringWriter); dataGrid.RenderControl(htmlTextWriter); Response.Write("<html><body><table><tr><td>A</td><td>B</td></tr><tr><td>C</td><td>D</td></tr></table></body></html>"); Response.End(); } produces the same error. What can cause such behavior? Is it because the Viewer cannot read such files, but full Excel version can?

    Read the article

  • Using generics with XmlSerializer

    - by MainMa
    Hi, When using XML serialization in C#, I use code like this: public MyObject LoadData() { XmlSerializer xmlSerializer = new XmlSerializer(typeof(MyObject)); using (TextReader reader = new StreamReader(settingsFileName)) { return (MyObject)xmlSerializer.Deserialize(reader); } } (and similar code for deserialization). It requires casting and is not really nice. Is there a way, directly in .NET Framework, to use generics with serialization? That is to say to write something like: public MyObject LoadData() { // Generics here. XmlSerializer<MyObject> xmlSerializer = new XmlSerializer(); using (TextReader reader = new StreamReader(settingsFileName)) { // No casts nevermore. return xmlSerializer.Deserialize(reader); } }

    Read the article

  • Visual Studio 2010 Extensibility, MPF and language services

    - by MainMa
    Hi, I am trying to extend Visual Studio 2010 RC to be able to use a custom programming language. The first two things I've tried to do is a syntax highlight/Intellisense feature (easily done, thanks to "Ook!" sample from PDC09) and a possibility to create new project templates (i.e. be able to open *.myproj files). For this second task, I can't find any easy tutorials or samples. Most samples are for Visual Studio 2008 (as for IronPython integration) or even VS2003. The few samples available for VS2010 do not work (including MPFProj) or do not compile, and are too hard to understand. Is there any easy-to-understand sample, either using MPFProj or a standalone solution, showing how to integrate templates for a custom language inside Visual Studio 2010?

    Read the article

  • .NET application per-machine/per-user licensing

    - by MainMa
    I am about to implement a very basic licensing feature for my application. A serial number may be granted per-machine (or per-operating-system) or per-user (as for CAL in Windows Server: if my application is used by several users on one machine or if it is used by one user on several machines). For per-operating-system licensing, I use SerialNumber of Win32_OperatingSystem. For per-user licensing, I use: WindowsIdentity currentIdentity = WindowsIdentity.GetCurrent(); if (currentIdentity != null) { SecurityIdentifier userSid = currentIdentity.User.AccountDomainSid; Console.WriteLine(userSid); } A hash of an obtained OS serial number or SID is then stored in the database, associated with application serial; each time the program starts, it queries the server, sending hash of OS SN/SID and application serial. Is it a right thing to do it or is it completely wrong? Will it work on every Windows machine? (For example, using motherboard serial is wrong)

    Read the article

  • Group SQL tables in SQL Server Management Studio object explorer

    - by MainMa
    I have a table which has approximately sixty tables, and other tables are added constantly. Each table is a part of a schema. A such quantity of tables makes it difficult to use Microsoft SQL Server Management Studio 2008. For example, I must scroll up in object explorer to access database related functions, or scroll down each time I need to access Views or Security features. Is it possible to group several tables to be able to expand or collapse them in Object Explorer? Maybe a folder may be displayed for each schema, letting collapse the folders I don't need to use?

    Read the article

  • What's wrong with my cross-thread call in Windows Forms?

    - by MainMa
    Hi, I encounter a problem with a Windows Forms application. A form must be displayed from another thread. So in the form class, I have the following code: private delegate void DisplayDialogCallback(); public void DisplayDialog() { if (this.InvokeRequired) { this.Invoke(new DisplayDialogCallback(DisplayDialog)); } else { this.ShowDialog(); } } Now, every time I run this, an InvalidOperationException is thrown on the line this.ShowDialog();: "Cross-thread operation not valid: Control 'SampleForm' accessed from a thread other than the thread it was created on." What's wrong with this piece of code? Isn't it a valid way to make cross-thread calls? Is there something special with ShowDialog()?

    Read the article

  • Backup Active Directory only

    - by MainMa
    Hi, I have a server with Windows Server 2008. I want to install a new Windows Server 2008 R2 on a new hard disk but on a same machine. What is the way to backup/migrate only Active Directory? I found that migration must be done with Microsoft Active Directory Migration Tool, but it requires both source and target domains running at the same time. Any other suggests are to use an ordinary system backup/restore, but this will restore all other roles, whereas I need only Active Directory role on the new server.

    Read the article

  • A very basic auto-expanding list/array

    - by MainMa
    Hi, I have a method which returns an array of fixed type objects (let's say MyObject). The method creates a new empty Stack<MyObject>. Then, it does some work and pushes some number of MyObjects to the end of the Stack. Finally, it returns the Stack.ToArray(). It does not change already added items or their properties, nor remove them. The number of elements to add will cost performance. There is no need to sort/order the elements. Is Stack a best thing to use? Or must I switch to Collection or List to ensure better performance and/or lower memory cost?

    Read the article

  • C# application per-machine/per-user licensing

    - by MainMa
    Hi, I am about to implement a very basic licensing feature for my application. A serial number may be granted per-machine (or per-operating-system) or per-user (as for CAL in Windows Server: if my application is used by several users on one machine or if it is used by one user on several machines). For per-operating-system licensing, I use SerialNumber of Win32_OperatingSystem. For per-user licensing, I use: WindowsIdentity currentIdentity = WindowsIdentity.GetCurrent(); if (currentIdentity != null) { SecurityIdentifier userSid = currentIdentity.User.AccountDomainSid; Console.WriteLine(userSid); } A hash of an obtained OS serial number or SID is then stored in the database, associated with application serial; each time the program starts, it queries the server, sending hash of OS SN/SID and application serial. Is it a right thing to do it or is it completely wrong? Will it work on every Windows machine? (For example, using motherboard serial is wrong)

    Read the article

  • Custom roles in ASP.NET

    - by MainMa
    Hi, I am working on an ASP.NET website which uses forms authentication with a custom authentication mechanism (which sets e.Authenticated programmatically on protected void Login_Authenticate(object sender, AuthenticateEventArgs e)). I have an ASP.NET sitemap. Some elements must be displayed only to logged in users. Others must be displayed only to one, unique user (ie. administrator, identified by a user name which will never change). What I want to avoid: Set a custom role provider: too much code to write for a such basic thing, Transform the existing code, for example by removing sitemap and replacing it by a code-behind solution. What I want to do: A pure code-behind solution which will let me assign roles on authenticate event. Is it possible? How? If not, is there an easy-to-do workaround?

    Read the article

  • Why addming permissions to an existing AppDomain has no effect?

    - by MainMa
    Hi, I have a following code which behaves strangely in .NET 4.0: // AppDomain is created, and permissions which were added to `sandboxPermissions` are added successfully. sandboxAppDomain = AppDomain.CreateDomain("SandboxDomain", null, appDomainSetup, sandboxPermissions, new[] { commonStrongName }); // Trying to add a new permission to an AppDomain which is already created. sandboxAppDomain.PermissionSet.AddPermission(new FileIOPermission(FileIOPermissionAccess.AllAccess, @"C:\Some\Path\Here")); // Setting breakpoint to this line: `permissions` contains every permission which was added to `sandboxPermissions`, but no trace of C:\Some\Path\Here related permission. var permissions = sandboxAppDomain.PermissionSet.ToXml(); Every permission added before creating an AppDomain is just here, as expected. But adding permissions after an AppDomain is created has no effect at all. There are no exceptions thrown (nor first-chance ones). What can it be? If the framework method (AddPermission) fails to do what it was expected to do, mustn't it throw an exception?

    Read the article

  • Treat multiple IEnumerable objects as a single IEnumerable

    - by MainMa
    Hi, My question seems to be something easy, but I can't figure it out. Let's say I have a "root" IEnumerable of objects. Each object has IEnumerable of strings. How can I obtain a single IEnumerable of those strings? A possible solution is to do: public IEnumerable<string> DoExample() { foreach (var c in rootSetOfObjects) { foreach (var n in c.childSetOfStrings) { yield return n; } } } But maybe there is a magic solution with Linq?

    Read the article

  • Why does adding permissions to an existing AppDomain have no effect?

    - by MainMa
    Hi, I have a following code which behaves strangely in .NET 4.0: // AppDomain is created, and permissions which were added to `sandboxPermissions` are added successfully. sandboxAppDomain = AppDomain.CreateDomain("SandboxDomain", null, appDomainSetup, sandboxPermissions, new[] { commonStrongName }); // Trying to add a new permission to an AppDomain which is already created. sandboxAppDomain.PermissionSet.AddPermission(new FileIOPermission(FileIOPermissionAccess.AllAccess, @"C:\Some\Path\Here")); // Setting breakpoint to this line: `permissions` contains every permission which was added to `sandboxPermissions`, but no trace of C:\Some\Path\Here related permission. var permissions = sandboxAppDomain.PermissionSet.ToXml(); Every permission added before creating an AppDomain is just here, as expected. But adding permissions after an AppDomain is created has no effect at all. There are no exceptions thrown (nor first-chance ones). What can it be? If the framework method (AddPermission) fails to do what it was expected to do, mustn't it throw an exception?

    Read the article

  • Microsoft products such as Visual Studio 2010 does not require to enter serial number

    - by MainMa
    Hi, I am member of WebsiteSpark and was member of DreamSpark. Both programs enable to download software and provide serial keys to use. Some software like Windows Server has an ISO file to download and a serial number displayed on the website which I must enter during installation. Some other software does not have any serial key. For example, when I downloaded Visual Studio 2010, there was just a link to an ISO file. During installation, there was no such a field as serial number (whereas Visual Studio 2008 had this field at the beginning of installation process). There is the same thing with SQL Server 2008 and Microsoft Expression Studio 3. Even when I've downloaded the public trial RTM version of Windows Seven Enterprise, there were no serial number to enter. I don't think that such expensive products as SQL Server 2008 Enterprise are delivered without serials and online validation, so I suppose that the serial is embedded into the product itself, either in installation binaries or in a separate config file, so is already in the ISO I download so I do not have to enter it. So my question is, how it is done technically? Is each 2 GBs ISO generated on-demand on the server to embed a serial each time this ISO is requested? I suppose that if it is done, it has a huge impact on servers performance (no caching, no streaming...), so what may be the techniques used behind? I want to implement the same feature in a product I intend to ship (to simplify installation by avoiding to ask to enter serial number), but I really don't see how to do it with low impact on server performance.

    Read the article

  • Executing untrusted code

    - by MainMa
    Hi, I'm building a C# application which uses plug-ins. The application must guarantee to the user that plug-ins will not do whatever they want on the user machine, and will have less privileges that the application itself (for example, the application can access its own log files, whereas plug-ins cannot). I considered three alternatives. Using System.AddIn. I tried this alternative first, because it seamed much powerful, but I'm really disappointed by the need of modifying the same code seven times in seven different projects each time I want to modify something. Besides, there is a huge number of problems to solve even for a simple Hello World application. Using System.Activator.CreateInstance(assemblyName, typeName). This is what I used in the preceding version of the application. I can't use it nevermore, because it does not provide a way to restrict permissions. Using System.Activator.CreateInstance(AppDomain domain, [...]). That's what I'm trying to implement now, but it seems that the only way to do that is to pass through ObjectHandle, which requires serialization for every used class. Although plug-ins contain WPF UserControls, which are not serializable. So is there a way to create plug-ins containing UserControls or other non serializable objects and to execute those plug-ins with a custom PermissionSet ?

    Read the article

  • Group SQL tables in Microsoft SQL Server Management Studio object explorer

    - by MainMa
    I have a table which has approximately sixty tables, and other tables are added constantly. Each table is a part of a schema. A such quantity of tables makes it difficult to use Microsoft SQL Server Management Studio 2008. For example, I must scroll up in object explorer to access database related functions, or scroll down each time I need to access Views or Security features. Is it possible to group several tables to be able to expand or collapse them in Object Explorer? Maybe a folder may be displayed for each schema, letting collapse the folders I don't need to use?

    Read the article

  • What is @namespace field in C# class?

    - by MainMa
    Hi, I'm browsing the source code of StyleCop, and I found a curious thing: /// <summary> /// The namespace that the rule is contained within. /// </summary> private string @namespace; // [...] internal Rule(string name, string @namespace, string checkId, string context, bool warning) : this(name, @namespace, checkId, context, warning, string.Empty, null, true, false) { Param.Ignore(name, @namespace, checkId, context, warning); } What is this thing? Is it just a simple field where at-sign is used to indicate that it is a field, and not a namespace keyword? If so, may at-sign be used for any reserved word (for example @dynamic, @using, etc.)?

    Read the article

  • Why ASP.NET menu control ignores roles in Web.sitemap?

    - by MainMa
    Hi, I have a website with a menu based on sitemap. ActiveDirectoryRoleProvider is a custom class. securityTrimmingEnabled of sitemap provider is set to true. Now, nevertheless the roles set in the sitemap file, site menu displays every sitemap entity. So for example if I have in sitemap a node with roles="*", a second one with roles="Administrators" and a third one with roles="Foo" and I login as a member of Administrators group but not Foo group, the site menu will display all three items. On the other hand, if I have a node which does not specify roles attribute but has children, this node will never be displayed. If I put: <%= HttpContext.Current.User.IsInRole("Administrators") ? "Admin" : "Not admin"%> <%= HttpContext.Current.User.IsInRole("Foo") ? "Foo" : "Not foo"%> before the menu, it displays that I'm Admin, but Not foo, which is just fine. So if it knows that I'm Admin but Not foo, why does it continue to display Foo's sitemap nodes? Note: changing authorizations has no effect on the menu. It continues to show every item, even for the pages I'm unable to access.

    Read the article

  • What about parallelism across network using multiple PCs?

    - by MainMa
    Parallel computing is used more and more, and new framework features and shortcuts make it easier to use (for example Parallel extensions which are directly available in .NET 4). Now what about the parallelism across network? I mean, an abstraction of everything related to communications, creation of processes on remote machines, etc. Something like, in C#: NetworkParallel.ForEach(myEnumerable, () => { // Computing and/or access to web ressource or local network database here }); I understand that it is very different from the multi-core parallelism. The two most obvious differences would probably be: The fact that such parallel task will be limited to computing, without being able for example to use files stored locally (but why not a database?), or even to use local variables, because it would be rather two distinct applications than two threads of the same application, The very specific implementation, requiring not just a separate thread (which is quite easy), but spanning a process on different machines, then communicating with them over local network. Despite those differences, such parallelism is quite possible, even without speaking about distributed architecture. Do you think it will be implemented in a few years? Do you agree that it enables developers to easily develop extremely powerfull stuff with much less pain? Example: Think about a business application which extracts data from the database, transforms it, and displays statistics. Let's say this application takes ten seconds to load data, twenty seconds to transform data and ten seconds to build charts on a single machine in a company, using all the CPU, whereas ten other machines are used at 5% of CPU most of the time. In a such case, every action may be done in parallel, resulting in probably six to ten seconds for overall process instead of forty.

    Read the article

  • Why isn't it possible to update an ObservableCollection from a different thread?

    - by MainMa
    In a multi-threaded WPF application, it is not possible to update an ObservableCollection from a thread other than WPF window thread. I know there are workarounds, so my question is not how to avoid the "This type of CollectionView does not support changes to its SourceCollection from a thread different from the Dispatcher thread" exception. My question is, why there is such an exception? Why wasn't it possible to allow collection updates from any thread? Personally, I don't see any reason to block UI update when ObservableCollection is changed from other threads. If two threads (including parallel ones) are accessing the same object, one listening for changes of object properties through events, the other one doing changes, it will always work, at least if locks are used properly. So, what are the reasons?

    Read the article

  • Alt attribute encoding with JavaScript

    - by MainMa
    Hi, Html entities must be encoded in alt attribute of an image in HTML page. So <img id="formula" alt="A &rarr; B" src="formula.png" /> will work well. On the other hand, the same JavaScript code will not work document.getElementById('formula').alt = 'A &rarr; B'; and will produce A &rarr; B instead of A → B. How to do it through JavaScript, when it is not possible to put the special (unencoded) characters in the source code?

    Read the article

< Previous Page | 1 2