I am trying to connect to skydrive with this code, it is console C# application:
var client = new SkyDriveServiceClient();
client.LogOn("username", "password");
and I got this exception: The operation has timed out.
Anyone know what is solution for this problem?
Ok, download the latest version (Changset 68942) from this
location. After download open the project (located in folder trunk/src/SkyDriveServiceClient.sln) in Visual Studio and change the variable SkyDocsServiceUri in the class SkyDocsServiceClient to the following:
public static readonly Uri SkyDocsServiceUri = new Uri("https://docs.live.net/SkyDocsService.svc");
After the change compile the project to build the assembly file. Then you need to reference the assembly from your project and try to execute your code again.
Related
I am trying to learn JsReport using c# and .NET core and visual studio. I have installed the required nuget packages (jsreport.binary and jsreport.Local). I am trying to replicate the code found Here. The problem is that I keep getting the following error.
***Severity Code Description Project File Line Suppression State
Error MSB3021 Unable to copy file "C:\Users\jmodiba\source\repos\js\js\obj\Debug\net6.0\apphost.exe" to "bin\Debug\net6.0\js.exe". Access to the path 'bin\Debug\net6.0\js.exe' is denied. js C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets 5097***
here is the code,
using jsreport.Binary;
using jsreport.Local;
using jsreport.Types;
var rs = new LocalReporting().UseBinary(JsReportBinary.GetBinary()).AsUtility().Create();
await rs.RenderAsync(new RenderRequest()
{
Template = new Template()
{
Recipe = Recipe.ChromePdf,
Engine = Engine.None,
Content = "Hello from pdf"
}
});
I managed to find the problem. My antivirus kept on moving the .exe file created to quarantine. Once I created an exception in the antivirus setting my code ran correctly.
I am writing a code to upload a file to an sftp server via WinSCP.
Everything else in my code works except when i started to include WinSCP into the code. The Assembly setup fails as it shows error where Object Reference not set to an instance of an object.
This is running on Windows Services using VS 2010 included with WinSCP .net references.
Below is the code that sets up the assembly , i am not able to use NuGet as that requires higher version of Visual Studio.
So i have to create this assembly which i got from WinSCP web itself however i do not understand what i am missing here.
try
{
Assembly executingAssembly = Assembly.GetExecutingAssembly();
string resName = executingAssembly.GetName().Name + "." + "WinSCP.exe";
using (Stream resource = Assembly.GetExecutingAssembly().GetManifestResourceStream(resName))
using (Stream file = new FileStream(executablePath, FileMode.Create, FileAccess.Write))
{
resource.CopyTo(file);
}
}
catch (System.Exception ex)
{
WriteToFile("Cant setup assembly : " + ex.Message);
Result should be that when the assembly successfully created , then the upload sessions will be able to go through as at the moment the upload sessions i am receiving an error "The version of C:\Windows\TEMP\WinSCP.tmp311D.exe () does not match version of this assembly somedir\WinSCPnet.DLL (5.15.2.0)."
A small assistance will be very helpful.
I found the problem. Apparently, I already have the assembly, that is why the error mentioned that I have the wrong assembly version. But, the main reason it couldn't match is because
The temp WinSCP is created in a folder where my program does not have access to.
I copy-pasted the WinSCP exe instead of Adding via "Add Item" in VS.
I then hard code the executable path to the WinSCP.exe to fix assembly looking into the wrong folder.
My problem has been solved.
When I run this code under my account in Visual Studio debugger
_alprNet = new AlprNet("eu", "openalpr.conf", "runtime_data");
if (!_alprNet.IsLoaded())
{
Tools.LogError("!!! OpenALPR failed to load.");
It works OK and AlprNet loads.
But when I install the Windows service and start this service I get
"!!! OpenALPR failed to load."
with no additional information.
I have all the DLLs and the runtime_data in the folder where my windows service's exe file is installed, exactly the same way as it is in bin\Debug folder.
How to find the reason why AlprNet failed to load?
In case it is useful for anyone:
This line in OnStart method before creating new AlprNet fixed the problem:
System.IO.Directory.SetCurrentDirectory(System.AppDomain.CurrentDomain.BaseDirectory);
https://stackoverflow.com/a/10385563/2224701
Apparently the non .NET DLLs dependencies could not be solved without this.
I'm trying to run a local SSIS package from a C# console application. I've built both the package and the application using .Net 4.5.1 in VisualStudio 2012. When I say "local" I mean the SSIS package hasn't been deployed to a SQL Server; I'm just trying to call the .dtsx file from the file system. The SSIS package runs fine from within VisualStudio. Here's my code:
string pkgLocation = #"C:\Users\06717\Documents\Visual Studio 2012\Projects\RMA_Data_Cleanup\RMA_Data_Cleanup\";
string pkgName = "Package.dtsx";
Application app = new Application();
Package pkg = new Package();
DTSExecResult pkgResults = new DTSExecResult();
try
{
pkg = app.LoadPackage(pkgLocation + pkgName, null);
There's more after this, obviously, but the problem comes with the app.LoadPackage line. When I try to run it, this exception gets thrown:
The package failed to load due to error 0xC0011008 "Error loading from XML. No further detailed error information can be specified for this problem because no Events object was passed where detailed error information can be stored.". This occurs when CPackage::LoadFromXML fails.
I've googled this error message, and I haven't found anything that seems to apply to my case. One thing that occurs to me is that maybe I'm calling the wrong dtsx file. There's another one in the obj\Development folder. I've tried calling that one too, but I get the same exception. Am I calling the right file? Is there something I need to do from within Visual Studio, other than build the package, before I can do this? (pkgResults = Success, BTW)
I am using the following code to try to programmatically create Visual Studio 2015 projects on the fly from within an existing Console Application. Why you ask? We are putting together a library of all our code snippets and we want a test/proof test solution for each one, and since we have hundreds of these, we aren't going to do it manually.
Ultimately this will be in an MVC5 app as its own project (class library?) but for now we are just trying to get it functional within this console application.
I am trying to create a new solution with 2 projects (a console application and a unit test project).I am also not even sure I need the unit test project, or whether one even works with a console app since there is no option to add a unit test to a console app in VS2015 solution generation.
Here is the code;
public class CreateConsoleProjectsProgrammatically
{
private const string Vs2015Type = "VisualStudio.DTE.14.0";
private const string Vs2015ConsoleProject = #"X:\Code Library\Helpers\ConsoleApplication\csConsoleApplication.vstemplate";
private const string Vs2015UnitTestProject = #"X:\Code Library\Helpers\UnitTestProject\UnitTestProject.vstemplate";
private const string Vs2015CodeLibraryBasepath = #"X:\Code Library";
public static void CreateVsConsoleProjectProgrammatically(string filename)
{
// Create a solution with two projects in it, based on project
// templates, a console project and a unit test project.
var vsType = Type.GetTypeFromProgID(Vs2015Type);
//error line is below
var vsInstance= Activator.CreateInstance(vsType, true);
EnvDTE.DTE dte = (EnvDTE.DTE)vsInstance;
dte.MainWindow.Visible = false; // optional: set to true if you want to see VS doing its thing
// create a new solution
dte.Solution.Create(#"X:\Code Library\", filename);
var solution = dte.Solution;
// create a C# console application
solution.AddFromTemplate(Vs2015ConsoleProject,Path.Combine(Vs2015CodeLibraryBasepath,filename), filename);
// create a unit test project
solution.AddFromTemplate(Vs2015UnitTestProject, Path.Combine(Vs2015CodeLibraryBasepath, filename + "_Test"), filename + "_Test");
// save and quit
dte.ExecuteCommand("File.SaveAll");
dte.Quit();
}
}
Here is the error which is from the Activator.CreateInstance
Creating an instance of the COM component with CLSID {A2FA2136-EB44-4D10-A1D3-6FE1D63A7C05} from the IClassFactory failed due to the following error: 8001010a The message filter indicated that the application is busy. (Exception from HRESULT: 0x8001010A (RPC_E_SERVERCALL_RETRYLATER)).
Not sure why I am getting a server busy error. It almost seems like its because VS is already open? But how else would the new solution be generated? I tried closing the solution and reopening it but that did nothing to solve the issue.
I also thought it may have been a connectivity issue, so I moved all the files and directories to C:\ but it produced the same error, so it wasn't an issue of using a networked drive location.
I also tried using
EnvDTE80.DTE2 dte2 = (EnvDTE100.DTE2)vsInstance;
but DTE2 is not an available property/method on EnvDTE100 according to the editor, even though I found some examples using it on the net.