I downloaded cudafy here: https://github.com/lepoco/CUDAfy.NET/releases/tag/v.1.0.0.
I use VS 2022, .NET 4.8.
When executing this code, I get System.ComponentModel.Win32Exception.
CudafyModes.Target = eGPUType.Cuda;
CudafyModes.DeviceId = 0;
CudafyTranslator.Language = CudafyModes.Target == eGPUType.OpenCL ? eLanguage.OpenCL : eLanguage.Cuda;
if (CudafyHost.GetDeviceCount(CudafyModes.Target) == 0)
throw new System.ArgumentException("No suitable devices found.", "original");
GPGPU gpu = CudafyHost.GetDevice(CudafyModes.Target, CudafyModes.DeviceId);
CudafyModule km = CudafyTranslator.Cudafy(); //THE EXCEPTION IS HERE
gpu.LoadModule(km);
StackTrace:
in System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
in Cudafy.NvccExe.getClExeDirectory()
in Cudafy.CompilerHelper.Create(ePlatform platform, eArchitecture arch, eCudafyCompileMode mode, String workingDir, Boolean debugInfo)
in Cudafy.Translator.CudafyTranslator.Cudafy()
in Game.Position..ctor() in C:\Users\Lenovo\Desktop\simple\simple\Position.cs:line 464
in Game.Position.StartPos() in C:\Users\Lenovo\Desktop\simple\simple\Position.cs:line 490
in Game.Board..ctor() in C:\Users\Lenovo\Desktop\simple\simple\Board.cs:line 189
in Game.FrmMain..ctor() in C:\Users\Lenovo\Desktop\simple\simple\FrmMain.cs:line 18
in Game.Program.Main() in C:\Users\Lenovo\Desktop\simple\simple\Program.cs:line 19
Exception information:
ErrorCode -2147467259 int
HResult -2147467259 int
HelpLink null string
InnerException null
NativeErrorCode 2 int
Source "System" string
TargetSite {Boolean StartWithCreateProcess(System.Diagnostics.ProcessStartInfo)} System.Reflection.MethodBase {System.Reflection.RuntimeMethodInfo}
The Path environment variable is declared:
Path C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\bin\Hostx64\x64
Cuda Toolkit 11.6 has been downloaded.
What can I do about it?
I solved the problem by connecting the source code. In particular, the program did not find the path to the utility vswhere.exe. Also the CUDA Toolkit required VS2010.
Related
Today i run Visual Studio and open my project, that i not opened about 5 months.
And running test (it was be OK) invoke IOException with additional information: "Bad descriptor".
It was in this line:
var defaultConsoleEncoding = Console.InputEncoding;
Console.InputEncoding = TryGetEncoding("UTF-8"); // <--- There is error
...
public static Encoding TryGetEncoding(string encoding)
{
try
{
return Encoding.GetEncoding(encoding);
}
catch (ArgumentException)
{
Logger.WarnAndPrint($"Can't using {encoding} encoding. Fallback to utf-8");
return Encoding.UTF8;
}
}
All my tests were OK, but now all fails with that error. I never chage code in project. And i try many encodings - nothing work.
What's the problem?
P.S. This is stack trace
System.IO.IOException was unhandled by user code
HResult=-2147024890
Message=Неверный дескриптор.
Source=mscorlib
StackTrace:
в System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
в System.Console.set_InputEncoding(Encoding value)
в PasswordListGenerator.Substitutions.Substitution.Process() в C:\GITHUB\passwordlistgenerator\PasswordListGenerator\PasswordListGenerator\Substitutions\Substitution.cs:строка 89
в PasswordListGeneratorTest.SubstitutionTests.SkipManySymbols_ShouldReturnSubstitutions() в C:\GITHUB\passwordlistgenerator\PasswordListGenerator\PasswordListGeneratorTest\SubstitutionTests.cs:строка 588
InnerException:
When trying to use the Range.Validation.Add() method, I'm consistently getting a very unfriendly error:
************** Exception Text **************
System.Runtime.InteropServices.COMException (0x800A03EC): Exception from HRESULT: 0x800A03EC
at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
at Microsoft.Office.Interop.Excel.Validation.Add(XlDVType Type, Object AlertStyle, Object Operator, Object Formula1, Object Formula2)
at TravelPlannerTools.Sheet8.OperaCodesDropDown() in C:\Users\Michael Utz\Documents\Visual Studio 2015\Projects\TravelPlannerTools\TravelPlannerTools\Sheet8.cs:line 39
at TravelPlannerTools.Sheet8.Sheet8_Startup(Object sender, EventArgs e) in C:\Users\Michael Utz\Documents\Visual Studio 2015\Projects\TravelPlannerTools\TravelPlannerTools\Sheet8.cs:line 27
at Microsoft.Office.Tools.Excel.WorksheetImpl.OnStartup()
at Microsoft.Office.Tools.Excel.WorksheetImpl.WorksheetExtensionImpl.Microsoft.Office.Tools.EntryPoint.OnStartup()
at Microsoft.Office.Tools.Excel.WorksheetBase.OnStartup()
at TravelPlannerTools.Sheet8.FinishInitialization() in C:\Users\Michael Utz\Documents\Visual Studio 2015\Projects\TravelPlannerTools\TravelPlannerTools\Sheet8.Designer.cs:line 50
at Microsoft.Office.Tools.Excel.WorksheetBase.Microsoft.Office.Tools.EntryPoint.FinishInitialization()
at Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.ExecuteCustomization.ExecutePhase(ExecutionPhases executionPhases)
at Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.ExecuteCustomization.Microsoft.VisualStudio.Tools.Office.Runtime.Interop.IExecuteCustomization2.ExecuteEntryPoints()
************** Loaded Assemblies **************
I am using the proper version of Excel and trying to perform a very simple task.
var list = new List<string>();
list.Add("Lann");
list.Add("Latl");
list.Add("LBBB");
var flatList = string.Join(",", list.ToArray());
var cell = Globals.Sheet8.Cells.Range["A2"];
cell.Validation.Delete();
cell.Validation.Add(
Excel.XlDVType.xlValidateList,
Excel.XlDVAlertStyle.xlValidAlertStop,
Excel.XlFormatConditionOperator.xlBetween,
flatList,
System.Type.Missing
);
cell.Validation.IgnoreBlank = true;
cell.Validation.InCellDropdown = true;
Any ideas?
The cell I was trying to write to was on a protected sheet. Using the Worksheet.Protect() and Worksheet.Unprotect() methods to toggle protection before and after the operation cleared up the error!
I am currently trying to move an existing project from VS 2005 to VS 2012. The project is written in C# and contains some even older code in C++ which is used as the core for some specific scientific calculations. Those parts are connected by a wrapping layer in C++.
I opened the existing main project in VS 2012 and let it do it's thing importing the older project files. Then I tried compiling each project one-by-one. I replaced some older libraries (e.g. boost) and am now stuck.
I am getting this error which I cannot solve because VS will not tell me at which line the error occurs. I tried Resharper but it does not seem to find an error in this particular project (although I'm using Resharper for the first time and it finds hundreds of errors and warnings all over the other projects).
1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\CodeAnalysis\Microsoft.CodeAnalysis.targets(342,5): error MSB4018: The "NativeCodeAnalysis" task failed unexpectedly.
1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\CodeAnalysis\Microsoft.CodeAnalysis.targets(342,5): error MSB4018: Microsoft.VisualStudio.CodeAnalysis.AnalysisResults.AnalysisResultException: CA0001 : An unknown error occurred while running Code Analysis. ---> System.ArgumentNullException: Value cannot be null.
1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\CodeAnalysis\Microsoft.CodeAnalysis.targets(342,5): error MSB4018: Parameter name: path2
1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\CodeAnalysis\Microsoft.CodeAnalysis.targets(342,5): error MSB4018: at System.IO.Path.Combine(String path1, String path2)
1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\CodeAnalysis\Microsoft.CodeAnalysis.targets(342,5): error MSB4018: at Microsoft.Build.Tasks.TaskCommon.GetRuleSetFullPath(String ruleSet, String projectDirectory, String[] ruleSetDirectories)
1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\CodeAnalysis\Microsoft.CodeAnalysis.targets(342,5): error MSB4018: at Microsoft.Build.Tasks.NativeCodeAnalysis.Execute()
1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\CodeAnalysis\Microsoft.CodeAnalysis.targets(342,5): error MSB4018: --- End of inner exception stack trace ---
1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\CodeAnalysis\Microsoft.CodeAnalysis.targets(342,5): error MSB4018: at Microsoft.Build.Tasks.NativeCodeAnalysis.Execute()
1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\CodeAnalysis\Microsoft.CodeAnalysis.targets(342,5): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\CodeAnalysis\Microsoft.CodeAnalysis.targets(342,5): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__20.MoveNext()
I spent hours trying to find a solution to my problem. So if my question is badly asked - please try to help nonetheless and tell me what information is needed.
This is the code of the project's .cpp-file:
namespace Trace
{
CTraceWrapper::CTraceWrapper(const char *LibName) : CBaseWrapper(LibName), m_GetTraceTextProc(NULL)
{
if (m_hModInstance != NULL)
{
m_GetTraceTextProc = (tGetTraceText)GetProcAddress(m_hModInstance, "getTraceText");
}
}
int CTraceWrapper::getTraceText(t_TraceTextMap& traceTextMap, bool bDelete)
{
#ifdef _TRACE_ACTIVE
if (m_GetTraceTextProc == NULL)
{
return RESULT_ERR_INVALID_FUNCTION_HANDLE;
}
m_GetTraceTextProc(traceTextMap, bDelete);
#endif
return RESULT_OK;
}
CTraceWrapper Wrapper("trace.dll");
int TraceWrapper::GetTraceList(array<TraceData^> ^%traceMap, bool bDelete)
{
t_TraceTextMap traceTextMap;
int nRet = Wrapper.getTraceText(traceTextMap, bDelete);
if (nRet != 0)
{
return nRet;
}
TraceData^ Data;
String^ Tmp;
array<String^> ^Split;
int Length = 0;
if (nRet == RESULT_OK)
{
traceMap = gcnew array<TraceData^>(traceTextMap.size());
int i = 0;
for (t_TraceTextMap::const_iterator cit = traceTextMap.begin(); cit != traceTextMap.end(); cit++)
{
Data = gcnew TraceData();
Data->Time = cit->first;
Tmp = gcnew String(cit->second.chars());
Split = Tmp->Trim()->Split('|');
Data->Type = Convert::ToInt16(Split[0], CultureInfo::CurrentCulture);
Data->Module = Convert::ToInt16(Split[1], CultureInfo::CurrentCulture);
Data->ProcessId = Convert::ToInt32(Split[2], CultureInfo::CurrentCulture);
Data->ThreadId = Convert::ToInt32(Split[3], CultureInfo::CurrentCulture);
Length = Split->GetLength(0);
Data->FunctionName = ((Length > 5) ? Split[5] : String::Empty);
Data->FileName = ((Length > 4) ? Split[4] : String::Empty);
Data->Line = ((Length > 6) ? Convert::ToInt32(Split[6], CultureInfo::CurrentCulture) : 0);
Data->Text = ((Length > 7) ? Split[7] : String::Empty);
if ((Data->Type == TRACE_TYPE_TIMING_END) && (Length > 8))
{
Data->Interval = Convert::ToDouble(Split[8], CultureInfo::InvariantCulture);
}
traceMap[i++] = Data;
}
}
return RESULT_OK;
}
}
Try opening the csproj file for the project that's failing and examine that. In VS2015 csproj files are msbuild files. Thats one option I can think of, the other is to try turn off code analysis.
I am trying to call ghost script from my C# program, passing it some args to crop the footer of a PDF file, then overwrite the temp file with the new modified version.
I think I'm calling the gs.exe incorrectly. Does anyone see a reason that the string I'm passing to start(gs) doesn't work?
When trace the script, it triggers the catch when it gets to System.Diagnostics.Process.Start(gs);
This is the string that's being called in the process.start(gs) function
C:\gs\gs9.14\bin\gswin64c.exe -o C:\Users\myname\Desktop\assignment1\assignment1\data\temp\test.pdf -sDEVICE=pdfwrite -c "[/CropBox [24 72 559 794] /PAGES pdf mark" -f C:\Users\myname\Desktop\assignment1\assignment1\data\temp\test.pdf
This is the message that I get in my console.
System.ComponentModel.Win32Exception (0x80004005): The system cannot find the file specified
at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start(String fileName)
at assignment1.Program.cropPDFFooter(String tempPDF) in C:\Users\tessierd\Desktop\assignment1\assignment1\Program.cs:line 78
Then this is the code for my method.
public static void cropPDFFooter(string tempPDF)
{
try
{
byte[] croppedPDF = File.ReadAllBytes(tempPDF);
string gsPath = #"C:\gs\gs9.14\bin\gswin64c.exe";
List<string> gsArgsList = new List<string>();
gsArgsList.Add(" -o " + tempPDF);
gsArgsList.Add(" -sDEVICE=pdfwrite");
gsArgsList.Add(" -c \"[/CropBox [24 72 559 794] /PAGES pdfmark\"");
gsArgsList.Add(" -f " + tempPDF);
var gsArgs = String.Join(null, gsArgsList);
string gs = gsPath + gsArgs; // not needed anymore (see solution)
// * wrong code here.
// System.Diagnostics.Process.Start(gs);
// * Correct code below.
System.Diagnostics.Process.Start(gsPath, gsArgs);
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
Console.ReadLine();
}
}
System.Diagnostics.Process.Start(gs); takes 2 parms. a file, and then args.
I had to change the code to
System.Diagnostics.Process.Start(gsPath, gsArgs);
I would suggest you to use Ghostscript wrapper for .NET.
You can find one here: Ghostscript.NET on GitHub
Usage example can be found here: Ghostscript Processor C# Sample
There is also an example on how to add the watermark with a -c switch which postscript you can simply replace with your cropbox postscript: Ghostscript.NET - Passing Postscript commands (take a look at the bottom function)
in my program i have an exception, because i want to synchronize a local directory with a write protected networkDirectory.
Message:
Microsoft.Synchronization.MetadataStorage.MetadataStorageEngineException: Fehler bei einem Speichermodulvorgang. Fehlercode: 25039 (HRESULT = 0x80004005, Quellen-IID = {0C733A7A-2A1C-11CE-ADE5-00AA0044773D}, Parameter=(0, 0, 0, H:\filesync.metadata, , , )).
---> System.Runtime.InteropServices.COMException: Fehler bei einem Speichermodulvorgang. Fehlercode: 25039 (HRESULT = 0x80004005, Quellen-IID = {0C733A7A-2A1C-11CE-ADE5-00AA0044773D}, Parameter=(0, 0, 0, (sourceNetworkDirectory)\filesync.metadata, , , )).
I would like to avoid writing the 'filesync.metadata' to the sourceDirectory, or maybe change the path for writing the metaFile
Can someone help me?
Greetings from Andre
the constructor for the file sync provider allows you to specify an alternate location for the metadata file.