Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
A

Anindya Chatterjee

@Anindya Chatterjee
About
Posts
65
Topics
31
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Are the cloud services like GDrive, OneDrive relevant to common people? Are they really a necessity?
    A Anindya Chatterjee

    Does people really need could storage services like GDrive, OneDrive over cheap local storage? Does it have any relevance? Here is a link to a survey also - https://www.surveymonkey.com/s/PJXZ8B5[^]. Please submit your views there along with the comments to help understand the situation better.

    Regards, Anindya Chatterjee[^]

    Cloud Computing com hosting cloud help question

  • Cross-thread operation not valid: Control '' accessed from a thread other than the thread it was created on.
    A Anindya Chatterjee

    Ya you are right the solution is not advisable. I agree with you, but in this case as it was mentioned as a VS only problems during debugging that's why I have told him to do this. This will atleast allow your code to debug in VS. That's what he needed only. But still it is not a good practice. Using of delegates is the good way to do it.

    Regards, Anindya Chatterjee[^]

    C# csharp visual-studio winforms sysadmin debugging

  • How to fetch file from a folder within.the application
    A Anindya Chatterjee

    By any chance are you not aware of Application.StartupPath ?? Then yo don't have to do all these string manipulations..

    Regards, Anindya Chatterjee[^]

    C# csharp help tutorial question

  • Cross-thread operation not valid: Control '' accessed from a thread other than the thread it was created on.
    A Anindya Chatterjee

    Just put

    CheckForIllegalCrossThreadCalls = false;

    in the constructor of your main form in your Windows Application. It will solve the problem.

    Regards, Anindya Chatterjee[^]

    C# csharp visual-studio winforms sysadmin debugging

  • How to add XmlInclude attribute dynamically
    A Anindya Chatterjee

    I have the following classes

    [XmlRoot]
    public class AList
    {
    public List<B> ListOfBs {get; set;}
    }

    public class B
    {
    public string BaseProperty {get; set;}
    }

    public class C : B
    {
    public string SomeProperty {get; set;}
    }

    public class Main
    {
    public static void Main(string[] args)
    {
    var aList = new AList();
    aList.ListOfBs = new List<B>();
    var c = new C { BaseProperty = "Base", SomeProperty = "Some" };
    aList.ListOfBs.Add(c);

        var type = typeof (AList);
        var serializer = new XmlSerializer(type);
        TextWriter w = new StringWriter();
        serializer.Serialize(w, aList);
    }    
    

    }

    Now when I try to run the code I got an InvalidOperationException at last line saying that The type XmlTest.C was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically. I know that adding a [XmlInclude(typeof(C))] attribute with [XmlRoot] would solve the problem. But I want to achieve it dynamically. Because in my project class C is not known prior to loading. Class C is being loaded as a plugin, so it is not possible for me to add XmlInclude attribute there. I tried also with

    TypeDescriptor.AddAttributes(typeof(AList), new[] { new XmlIncludeAttribute(c.GetType()) });

    before

    var type = typeof (AList);

    but no use. It is still giving the same exception. Does any one have any idea on how to achieve it?

    Regards, Anindya Chatterjee[^]

    C# help tutorial question

  • how can i show progress in Progress bar on MDI form from child form
    A Anindya Chatterjee

    Follow some simple steps: 1. Make the progressBar internal so that child form can access it. 2. Now access the progress bar like (child.MdiParent as ParentForm).progressBar. 3. Make sure you have a synchronization mechanism is on place so that at a time only one child form can access the proressbar. [where child is the Child Form, ParentForm is the class name of the MDI form and progressBar is the control in MDI form.] Or, if you do not want to expose the control as internal then create some event in Child Form like

    public event EventHandler<ProgressChangedEventArgs> ProgressChanged;

    Then subscribe this event in parent form like

    child.ProgressChanged += Child_ProgressChanged;

    void Child_ProgressChanged(object sender, ProgressChangedEventArgs e)
    {
    // put your code here
    }

    and then call the event from child form like

    if(ProgressChanged != null)
    ProgressChanged(this, new ProgressChangedEventArgs(progressPercentage, null));

    Regards, Anindya Chatterjee[^]

    C# csharp docker help question

  • hashtable or Dictionary!
    A Anindya Chatterjee

    One thing to remind, if you try to save settings in either of the data structures as a xml file then you are out of luck, by default both of them are not serializable. You have to implement the IXmlSerializable interface in a custom object and wrap it around the hash table.

    Regards, Anindya Chatterjee[^]

    C# csharp question

  • Compare picturebox.image with image from a resource file
    A Anindya Chatterjee

    Use System.Drawing.Imaging.ImageFormat.Bmp instead. Here is the test code

    Image img1 = pictureBox1.Image;
    Image img2 = pictureBox2.Image;

            MemoryStream ms1 = new MemoryStream(), ms2 = new MemoryStream();
            
            img1.Save(ms1, ImageFormat.Bmp);
            img2.Save(ms2, ImageFormat.Bmp);
    
            byte\[\] byteArray1, byteArray2;
    
            byteArray1 = ms1.ToArray();
            byteArray2 = ms2.ToArray();
    
            if (byteArray1.Length == byteArray2.Length)
            {
                for (int i = 0; i < byteArray1.Length; i++)
                {
                    if(byteArray1\[i\] != byteArray2\[i\])
                        MessageBox.Show("Not Same");
                }
                MessageBox.Show("Image Same");
            }
            else
                MessageBox.Show("Not Same");
    

    Inform me if it solves the problem.

    Regards, Anindya Chatterjee[^]

    C# question tutorial learning

  • Checkboxes inside checklistbox
    A Anindya Chatterjee

    I am afraid, you can not access that checkboxes inside the checkedlistbox. But as a last resort we can try using checkedlistbox.Controls property and enumerates the child controls to see if you can get hold of that checkbox. But still I am sure that won't be of much help.

    Regards, Anindya Chatterjee[^]

    C#

  • Compare picturebox.image with image from a resource file
    A Anindya Chatterjee

    Some remarks for your code. 1. Use Image class directly instead of Bitmap. And don't use Jpeg format use MemoryBmp, it will ease byte comparing.

    bild.Image.Save(ms1, System.Drawing.Imaging.ImageFormat.MemoryBmp);

    2. Don't use

    if(byteArray1 == byteArray2)

    coz you are doing the same wrong thing again. I told you to compare byte by byte using looping like as follows

    if(byteArray1.Length == byteArray2.Length)
    {
    for(int i = 0; i < byteArray1.Length; i++)
    {
    if(byteArray1[i] != byteArray2[i])
    return false;
    }
    return true;
    }
    return false;

    Hope this will give you the desired result.

    Regards, Anindya Chatterjee[^]

    C# question tutorial learning

  • Compare picturebox.image with image from a resource file
    A Anindya Chatterjee

    That is because the equality operator only valid for the same objects not for the same contents. Though your pictures' contents are same but as they are two different objects in the memory, that is why the control always goes to the else block. Now comparing the two images is not so simple. One way to do is to save the two images in two different MemoryStream using

    var ms = new MemeoryStream();
    image.Save(ms, System.Drawing.Imaging.ImageFormat.MemoryBmp);
    byte[] byteArray = ms.ToArray();

    Do the same thing for the other image also and then check the equality of two byte arrays by reading each byte. Hope this will solve your problem.

    Regards, Anindya Chatterjee[^]

    C# question tutorial learning

  • How to put large text data (~20mb) into sql cs 3.5 database?
    A Anindya Chatterjee

    What I am following are a very simple steps as follows: Start application search for accounts in settings if nothing found show creation dialog create folder and storage tables save the settings if found check for folder structure if not synchronized create folders at folder table add its parent folder if any check for mails in each mail if not uptodate download mails for each folder and save to storage table if uptodate start the listeners

    Regards, Anindya Chatterjee[^]

    C# database question csharp sql-server sysadmin

  • How to put large text data (~20mb) into sql cs 3.5 database?
    A Anindya Chatterjee

    Hi Bob, Thanks for your reply. Let me tell you one thing that I am going to create a desktop mail storage. Still I am not sure how to store the messages in an elegant way. This was my first try to store the content of the message in sqlce db. Is there any other better way to do this?

    Regards, Anindya Chatterjee[^]

    C# database question csharp sql-server sysadmin

  • How to put large text data (~20mb) into sql cs 3.5 database?
    A Anindya Chatterjee

    I am using following query to insert some large text data :

    internal static string InsertStorageItem =
    "insert into Storage(FolderName, MessageId, MessageDate, StorageData) values ('{0}', '{1}', '{2}', @StorageData)";

    and the code I am using to execute this query is as follows :

    string content = "very very large data";
    string query = string.Format(InsertStorageItem, "Inbox", "AXOGTRR1445/DSDS587444WEE", "4/19/2010 11:11:03 AM");
    var command = new SqlCeCommand(query, _sqlConnection);
    var paramData = command.Parameters.Add("@StorageData", System.Data.SqlDbType.NText);
    paramData.Value = content;
    paramData.SourceColumn = "StorageData";
    command.ExecuteNonQuery();

    But at the last line I am getting this following error : System.Data.SqlServerCe.SqlCeException was unhandled by user code Message=The data was truncated while converting from one data type to another. [ Name of function(if known) = ] Source=SQL Server Compact ADO.NET Data Provider HResult=-2147467259 NativeError=25920 StackTrace: at System.Data.SqlServerCe.SqlCeCommand.ProcessResults(Int32 hr) at System.Data.SqlServerCe.SqlCeCommand.ExecuteCommandText(IntPtr& pCursor, Boolean& isBaseTableCursor) at System.Data.SqlServerCe.SqlCeCommand.ExecuteCommand(CommandBehavior behavior, String method, ResultSetOptions options) at System.Data.SqlServerCe.SqlCeCommand.ExecuteNonQuery() at Chithi.Client.Exchange.ExchangeClient.SaveItem(Item item, Folder parentFolder) at Chithi.Client.Exchange.ExchangeClient.DownloadNewMails(Folder folder) at Chithi.Client.Exchange.ExchangeClient.SynchronizeParentChildFolder(WellKnownFolder wellknownFolder, Folder parentFolder) at Chithi.Client.Exchange.ExchangeClient.SynchronizeFolders() at Chithi.Client.Exchange.ExchangeClient.WorkerThreadDoWork(Object sender, DoWorkEventArgs e) at System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e) at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument) InnerException: Now my question is how am I supposed to insert such large data to sqlce db?

    Regards, Anindya Chatterjee[^]

    C# database question csharp sql-server sysadmin

  • How to Save/Store non serializable objects
    A Anindya Chatterjee

    While coding for a MS Exchange email client I came up with a peculiar problem. I am using Exchange Web Service Managed API to access the exchange mail server and getting the mail messages. The problems occur when I try to store the message object into the disk. While serializing the object it is throwing a SerializationException saying that - "Type 'Microsoft.Exchange.WebServices.Data.EmailMessage' in Assembly 'Microsoft.Exchange.WebServices, Version=14.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' is not marked as serializable.". One thing is not clear to me, if the object is not serializable then how come it is being transferred through the web service? Secondly, do any one have any idea on how to store this non serializable object into disk. I am in a dire need. Thanks and regards,

    Anindya Chatterjee --------------------------------------------------------

    C# sysadmin json help tutorial question

  • 22 Most Unusual Google Earth Photos
    A Anindya Chatterjee

    Google Earth Pics[^]

    Anindya Chatterjee --------------------------------------------------------

    The Lounge com

  • Big Bang Test Successful, says CERN
    A Anindya Chatterjee

    May be or may not be. But let's hope for the best and good one. :)

    Anindya Chatterjee --------------------------------------------------------

    The Lounge com

  • Big Bang Test Successful, says CERN
    A Anindya Chatterjee

    The world's largest atom smasher has set a record for high-energy collisions by crashing two proton beams at three times more force than ever before in their attempt to create mini-versions of the Big Bang that led to the birth of the universe 13.7 billion years ago. {More Details ...[^]} Let's see what new theory we can get to know from this project.

    Anindya Chatterjee --------------------------------------------------------

    The Lounge com

  • Changing registry settings through .Net app
    A Anindya Chatterjee

    I tried with RegistryKey runKey = Registry.CurrentUser.OpenSubKey(@"\Software\Microsoft\Windows\CurrentVersion\Run", true); but runKey is getting always null in Win7 and XP also. What to do? Please help me out.

    Anindya Chatterjee -------------------------------------------------------- 1. Don't Visit ..[^] 2. But Watch ..

    C# csharp com windows-admin help tutorial

  • Changing registry settings through .Net app
    A Anindya Chatterjee

    Hi Friends, I want to do some registry settings changes through my .net app. Registry settings change will happen only in the "Settings" part of the app like "Starts at Windows" i.e. put an entry in the "Run" key. But to do this things in Win7 or Vista I am experiencing problems like Unauthorized access due to UAC. I am not being able to change the settings. I don't want to run the app in admin mode each time it runs, I just only want to elevate the permission at the time of changing the registry settings. Can anyone please help me out in this situation on how to accomplish this task like by modifying manifest file or putting permission attribute, anything at all. Thanks in advance.

    Anindya Chatterjee -------------------------------------------------------- 1. Don't Visit ..[^] 2. But Watch ..

    C# csharp com windows-admin help tutorial
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups