Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4023274
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:34:43+00:00 2026-05-20T10:34:43+00:00

So in my program I’m using COM Auotmation (AutomationFactory in Silverlight 4) to create

  • 0

So in my program I’m using COM Auotmation (AutomationFactory in Silverlight 4) to create a FileSystemObject, to which I write a string (theContent). theContent in this case is a small UTF-8 XML file, which I serialized using MemoryStream into the string.

The string is fine, but for some reason whenever I call the FileSystemObject’s Write method I get the error “HRESULT 0x800A0005 (CTL_E_ILLEGALFUNCTIONCALL from google).” The strangest part is that if I pass another simple string, like “hello,” it works with no problems.

Any ideas?

Alternatively, if there’s a way to expose a file/text stream with FileSystemObject that I could serialize to directly, that would be good as well (I can’t seem to find anything not in VB).

Thanks in advance!

string theContent = System.Text.Encoding.UTF8.GetString(content, 0, content.Length);
string hello = "hello";

 using (dynamic fsoCom = AutomationFactory.CreateObject("Scripting.FileSystemObject"))
 {
      dynamic file = fsoCom.CreateTextFile("file.xml", true);
      file.Write(theContent);
      file.Write(hello);
      file.Close();
 }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T10:34:44+00:00Added an answer on May 20, 2026 at 10:34 am

    I solved the same problem today using ADODB.Stream instead of Scripting.FileSystemObject.

    In a Silverlight 4 OOB App (even with elevated trust), you cannot access files in locations outside of ‘MyDocuments’ and a couple of other user related special folders. You have to use the workaround ‘COM+ Automation’. But the Scripting.FileSystemObject, which works great for text files, cannot handle binary files. Fortunately you can also use ADODB.Stream there. And that handles binary files just fine. Here is my code, tested with Word Templates, .dotx files:

    public static void WriteBinaryFile(string fileName, byte[] binary)
    {
        const int adTypeBinary = 1;
        const int adSaveCreateOverWrite = 2;
        using (dynamic adoCom = AutomationFactory.CreateObject("ADODB.Stream"))
        {
            adoCom.Type = adTypeBinary;
            adoCom.Open();
            adoCom.Write(binary);
            adoCom.SaveToFile(fileName, adSaveCreateOverWrite);
        }
    }
    

    A file read can be done like this:

    public static byte[] ReadBinaryFile(string fileName)
    {
        const int adTypeBinary = 1;
        using (dynamic adoCom = AutomationFactory.CreateObject("ADODB.Stream"))
        {
            adoCom.Type = adTypeBinary;
            adoCom.Open();
            adoCom.LoadFromFile(fileName);
            return adoCom.Read();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Strange program hang, what does this mean in debug? After attaching windbg I found
Program followed by output. Someone please explain to me why 10,000,000 milliseconds from Jan
Most program languages have some kind of exception handling; some languages have return codes,
My program generates relatively simple PDF documents on request, but I'm having trouble with
A program receives a list of Messages (base type). Each message in the list
My Program overrides public void paint(Graphics g, int x, int y); in order to
What program can I use to decompile a class file? Will I actually get
The program that I am currently assigned to has a requirement that I copy
A program that I work on assumes that the UUID generated by the Windows
My program has to read files that use various encodings. They may be ANSI,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.