COMException when using Windows API Code Pack - c#

I downloaded Windows® API Code Pack for Microsoft® .NET Framework from
http://code.msdn.microsoft.com/WindowsAPICodePack/Release/ProjectReleases.aspx?ReleaseId=3077
ERROR
On testing the solution on VS 2008,I get error in line
IKnownFolderManager knownFolderManager = (IKnownFolderManager)new KnownFolderManagerClass();
knownFolderManager.GetFolderIds(out folders, out count);
DETAILS BELOW,
System.Runtime.InteropServices.COMException was unhandled
Message="Retrieving the COM class factory for component with CLSID {4DF0C730-DF9D-4AE3-9153-AA6B82E9795A} failed due to the following error: 80040154."
Source="Microsoft.WindowsAPICodePack.Shell"
ErrorCode=-2147221164
StackTrace:
at Microsoft.WindowsAPICodePack.Shell.KnownFolders.GetAllFolders() in D:\WindowsAPICodePack\WindowsAPICodePack\Shell\KnownFolders\KnownFolders.cs:line 43
at Microsoft.WindowsAPICodePack.Shell.KnownFolders.get_All() in D:\WindowsAPICodePack\WindowsAPICodePack\Shell\KnownFolders\KnownFolders.cs:line 29
at Microsoft.WindowsAPICodePack.Samples.ExplorerBrowserTestForm..ctor() in D:\WindowsAPICodePack\Samples\ExplorerBrowser\CS\WinForms\ExplorerBrowserTestForm.cs:line 27
at Microsoft.WindowsAPICodePack.Samples.Program.Main() in D:\WindowsAPICodePack\Samples\ExplorerBrowser\CS\WinForms\Program.cs:line 18
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
QUESTION
Please help to resolve this error.

This error code means that the object you've requested is not registered on system. IKnownFolderManager appeared starting with Vista.

Related

Grapevine 3.1 - 'The process cannot access the file'

I have a solution that utilises Grapevine to start a server within the Program class.
For some reason though, as soon as I start the program, it crashes when server.Start() is called.
No other parts of the solution are running at this point, so I don't know how that could be happening?
Running in Visual Studio 15, as Administrator, on Windows 10.
Program.cs
using System;
using System.Threading;
using Grapevine.Server;
using QuantConnect.Logging;
namespace QuantConnect.Services
{
class Program
{
/// <summary>
/// QuantConnect C# Services Server:
/// </summary>
static void Main(string[] args)
{
var server = new RESTServer
{
//Host = Configuration.Config.Get("grapevine-host"),
//Port = Configuration.Config.Get("grapevine-port")
Host = Configuration.Config.Get("grapevine-host", "localhost"),
Port = Configuration.Config.Get("grapevine-port", "80")
};
Log.Trace(string.Format("Starting Server On {0}:{1}", server.Host, server.Port));
server.Start(); // Exception occurs here
while (server.IsListening)
{
Thread.Sleep(300);
}
Log.Trace("Server stopped. Press key to continue...");
Console.ReadLine();
}
}
}
Error and stacktrace:
An unhandled exception of type 'System.Net.HttpListenerException' occurred in Grapevine.dll
System.Net.HttpListenerException was unhandled
ErrorCode=32
HResult=-2147467259
Message=The process cannot access the file because it is being used by another process
NativeErrorCode=32
Source=System
StackTrace:
at System.Net.HttpListener.AddAllPrefixes()
at System.Net.HttpListener.Start()
at Grapevine.Server.RESTServer.Start()
at QuantConnect.Services.Program.Main(String[] args) in C:\Users\RichardsPC\Source\Repos\Lean\Services\Program.cs:line 29
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
So I figured out what the issue was.
I set Grapevine to use port 80.
Port = Configuration.Config.Get("grapevine-port", "80")
Issue was that there was another service on my machine using this port, I changed it to use 8080 and it works fine now.
Port = Configuration.Config.Get("grapevine-port", "8080")

A generic error occurred in GDI+ when trying to save image downloaded with WebClient

I've been having problems with I code I wrote. What this code does is download a picture from my server and puts it inside a PDF document. I've narrowed it down to a problem with the image being downloaded.
At first, I thought it was a problem with my project so I've created a new Console Application with just that code to test it out - but that happens on it as well.
What I'm trying to do is simple - download a picture with WebClient and save it to the disk:
WebClient oWebClient = new WebClient();
byte[] oImageBytes = oWebClient.DownloadData("http://images1.ynet.co.il/PicServer3/2013/12/25/5058381/505838001000100396220.jpg");
ImageConverter oConverter = new ImageConverter();
Image oImg = (Image)oConverter.ConvertFrom(oImageBytes);
oImg.Save("d:\\temp\\1.jpg");
The image url in the example is taken from a local news site and fails as well.
The very strange thing is that on windows 7 and earlier it works. It fails on Windows8 and Windows Server 2012 with the following error:
An unhandled exception of type 'System.Runtime.InteropServices.ExternalException' occurred in System.Drawing.dll
Additional information: A generic error occurred in GDI+.
This is the StackTrace:
at System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams)
at System.Drawing.Image.Save(String filename, ImageFormat format)
at System.Drawing.Image.Save(String filename)
at ConsoleApplication1.Program.Main(String[] args) in c:\Users\Ophir\Documents\Visual Studio 2013\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs:line 23
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
I've tried searching the web, but all solutions I found didn't work in my case.
The directory that I'm trying to save to has sufficient permissions.
Anyone has any idea to why this is happening ?
Thanks
What about to save data as is?
byte[] oImageBytes = oWebClient.DownloadData("http://images1.ynet.co.il/PicServer3/2013/12/25/5058381/505838001000100396220.jpg");
File.WriteAllBytes("d:\\temp\\1.jpg", oImageBytes);

Axiom framework NullReferenceException after calling root.Shutdown()

So I've written my own game class, which is initialized like so (BTW, this is F# not C#):
static member RunGame() =
use engine = new Root()
// For now, always use OpenGL
engine.RenderSystem <- engine.RenderSystems.["OpenGL"]
use renderWindow = engine.Initialize(true)
let game = new Game(engine, renderWindow)
game.Load()
engine.FrameStarted.Add(game.HandleInput)
engine.FrameRenderingQueued.Add(game.OnRenderFrame)
engine.StartRendering() // The error is thrown somewhere inside here
game.Unload()
and this is simply how I try to shut the system down:
static member this.HandleInput(e: FrameEventArgs) =
input.Capture()
if input.IsKeyPressed(KeyCodes.Escape) then
root.Shutdown
root is the first argument in the constructor, so it is the same object as engine in the first sample. Here's the full error:
System.NullReferenceException was unhandled
HResult=-2147467261
Message=Object reference not set to an instance of an object.
Source=Axiom
StackTrace:
at Axiom.Graphics.RenderTarget.Update(Boolean swapBuffers)
at Axiom.Graphics.RenderSystem.UpdateAllRenderTargets(Boolean swapBuffers)
at Axiom.Core.Root.UpdateAllRenderTargets()
at Axiom.Core.Root.RenderOneFrame()
at Axiom.Core.Root.StartRendering()
at MiningGameTest.Game.RunGame() in H:\Projects\FSharp\MiningGameTest\MiningGameTest\Game.fs:line 22
at MiningGameTest.Host.Axiom.Program.Main(String[] args) in h:\Projects\FSharp\MiningGameTest\MiningGameTest.Host.Axiom\Program.cs:line 14
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
And one more thing: not sure if this has anything to do with it, but I've also been getting the following errors immediately when the project launches:
A first chance exception of type 'System.DllNotFoundException' occurred in FreeImageNET.dll
A first chance exception of type 'System.DllNotFoundException' occurred in OpenTK.dll
A first chance exception of type 'System.TypeInitializationException' occurred in OpenTK.dll
A first chance exception of type 'System.DllNotFoundException' occurred in OpenTK.dll
A first chance exception of type 'System.NullReferenceException' occurred in Axiom.dll
Am I doing something wrong or is this an Axiom bug?
PS: I'm running under Windows 8 and Visual Studio 2012 Professional using the OpenGL render system.

PerlEmbed - C# doesn't work with Interpreter.Language = #"PerlScript"

Regarding to the method in:
PerlEmbed - C# - Mono - Linux
I got the following error when I tried to run the code above, at line
Interpreter.Language = #"**PerlScript**"
I can run a VBScript but unfortunately I couldn't run a PerlScript. Should I do/setup/add etc. something else?
System.Runtime.InteropServices.COMException was unhandled
HelpLink="MSSCRIPT.HLP"
Message="***A script engine for the specified language can not be created.***"
Source="ScriptControl"
ErrorCode=-2146827908
StackTrace:
at MSScriptControl.ScriptControlClass.set_Language(String pbstrLanguage)
at fpu_Parsing.Perl_Interpreter.Perl_Output_returnString() in D:\Documents and Settings\labuser\My Documents\Visual Studio 2005\Projects\fpu_Parsing\fpu_Parsing\Perl_Interpreter.cs:line 77
at fpu_Parsing.frmFpuAnalyzer..ctor() in D:\Documents and Settings\labuser\My Documents\Visual Studio 2005\Projects\fpu_Parsing\fpu_Parsing\frmFpuAnalyzer.cs:line 24
at fpu_Parsing.Program.Main() in D:\Documents and Settings\labuser\My Documents\Visual Studio 2005\Projects\fpu_Parsing\fpu_Parsing\Program.cs:line 17
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

Amazon S3 - The remote server returned an error: (407) Proxy Authentication

I am having the following code to upload a file in s3.
AmazonS3 s3Client = AWSClientFactory.CreateAmazonS3Client("AWSAccessKey", "AWSSecretKey");
String strS3KEY = "JSON_FILE_NAME";
PutObjectRequest request = new PutObjectRequest();
request.WithBucketName("AWS_BUCKET");
request.WithKey(strS3KEY);
request.WithContentBody("Test");
request.CannedACL = S3CannedACL.PublicRead;
s3Client.PutObject(request);
This works find in the local system. When I run the application from deployment server in the line s3Client.PutObject(request); it gives the following error-
The remote server returned an error: (407) Proxy Authentication Required.
The stack trace is -
at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
at System.Net.HttpWebRequest.GetRequestStream()
at Amazon.S3.AmazonS3Client.getRequestStreamCallback[T](IAsyncResult result)
at Amazon.S3.AmazonS3Client.endOperation[T](IAsyncResult result)
at Amazon.S3.AmazonS3Client.EndPutObject(IAsyncResult asyncResult)
at Amazon.S3.AmazonS3Client.PutObject(PutObjectRequest request)
at XMLandCloudConsole.Program.Main(String[] args) in C:\Users\spxc\Desktop\consoletest \XMLandCloudConsole\XMLandCloudConsole\Program.cs:line 29
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

Categories

Resources