|
Richard Deeming wrote: Convert.ToInt32 does not allow you to use a Hex prefix. Neither the VB prefix (&H ) nor the C# prefix (0x ) will work.
Huh?
"If fromBase is 16, you can prefix the number specified by the value parameter with "0x" or "0X"."
Convert.ToInt32 Method (String, Int32) (System)[^]
|
|
|
|
|
Only on the overload that takes the "from base" parameter. That's not the overload the OP was calling.
Convert.ToInt32("2A", 16)
Convert.ToInt32("0x2A", 16)
Convert.ToInt32("&H2A", 16)
Convert.ToInt32("0x2A")
Convert.ToInt32("&H2A")
I'll edit the message to clarify.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|
Getting this error.
System.AccessViolationException was unhandled
Message: An unhandled exception of type 'System.AccessViolationException' occurred in AxInterop.ShockwaveFlashObjects.dll
Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
When I have Adobe Flash security updates installed.
Using this code
Flash.Movie("movie.swf")
Flash.Play
Then
Flash.LoadMovie(1, "crash.swf") 'Crashes when Adobe Flash is updated, doesn't allow top layer SWF to interact with Movie/base.
To load multiple SWF layers at same time crashes. I'm guessing the security update did something so you can't write layered SWF code to the original SWF's memory. I don't know why this is, but is there any fix or will there be one? This has been like this for about a year now, and it doesn't seem like it'll be addressed.
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at ShockwaveFlashObjects.IShockwaveFlash.LoadMovie(Int32 layer, String url)
at AxShockwaveFlashObjects.AxShockwaveFlash.LoadMovie(Int32 layer, String url)
at AEDab.Form1.ListBox1_SelectedIndexChanged(Object sender, EventArgs e) in C:\Users\UDA\Documents\Visual Studio 2013\Projects\uh\uh\Form1.vb:line 77
at System.Windows.Forms.ListBox.OnSelectedIndexChanged(EventArgs e)
at System.Windows.Forms.ListBox.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
|
|
|
|
|
You probably need to report this to Adobe and check with them for a fix.
|
|
|
|
|
I've tried but I've never gotten a response. This has been over a year so far, multiple attempts to contact but all have been ignored.
|
|
|
|
|
Hi,
I am getting the following error no matter what path I am giving for this file to load into a Table in the Database from Excel using Jet Engine
The path I have tried are
1. I kept the file on my local machine to run the Package from my Local machine, it said invalid Path (C:\Users\aaleem01\Desktop\Project Documents\Tucker Package\Daily Facets Report 8.21.17.xls)
2. I kept the shared drive/folder, still it gave me in valid file path (Z:\FileWatcher\Daily Facets Report 8.21.17.xls)
3. Then I dropped the file on the Server where Sql Server instance is running and used that path in creating the Connection string for Excel, still it gave me the same error
Can anybody tell me what could be wrong in my file Path, I am trying to execute a Script Task in which I load data from Excel file into a Sql Server Table.
Here is how my Code looks like:
string excelConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Dts.Variables["ExcelFullPath"].Value + ";Extended Properties=Text;";
string sqlConnectionString = "Data Source=" + Dts.Variables["ServerName"].Value + ";Initial Catalog="
+ Dts.Variables["Saw_Raw_DatabaseName"].Value
+ ";Integrated Security=SSPI;";
using (OleDbConnection conn = new OleDbConnection(excelConnectionString))
{
if (conn.State != ConnectionState.Open)
conn.Open();
using (OleDbCommand oleCmd = new OleDbCommand("select * from [" + Dts.Variables["SheetName"].Value + "$]", conn))
{
using (OleDbDataReader reader = oleCmd.ExecuteReader())
{
InsertData(Dts.Variables["TableName"].Value.ToString(), reader, sqlConnectionString);
}
if (conn.State != ConnectionState.Closed)
conn.Close();
}
}
The exact error is as follows:
'C:\SSIS Packages\TempFiles\Daily Facets Report 8.21.17.xls' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.
Any type of help can be very helpful like Code snippet, a link or a suggestion. Thanks in advance friends.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
modified 29-Aug-17 19:48pm.
|
|
|
|
|
|
It is fairly clear that the path in the error message is not the same as either of the locations where that file is actually stored.
I notice also that you are using Extended Properties=Text; to read an Excel workbook. That is not correct, you should use Extended Properties=Excel 8.0; . See Working with MS Excel(xls / xlsx) Using MDAC and Oledb[^].
|
|
|
|
|
How can i show a pie chart crystal report showing monthly auto sales for all models ( crosswind, d-max, alterra, Mu-X, N-Series, F-Series)?
|
|
|
|
|
|
Hi,
I am starting a process using P/Invoke of
CreateProcessWithTokenW
Eyerthing works fine, e.g. when I run a simple command like "ipconfig > test.log" then the file contains the output of the file. Process Explorer also tells me that the process runs as the user I impersonated to...
When I start a GUI application, however, I run into a strange problem: The process starts without error and the icon of the process pops up in the taskbar (e.g. the notepad icon), but I cannot "look at the GUI". Its a bit hard to explain, but I can click on the taskbar icon and a frame of the Window appears, but is has no "contents". I can click on the close icon and the windows closes.
Please refer to this screenshot. It also shows that this is not a "move to screen" issue
ScreenShot
I'd be happy for all sorts of advice.
Cheers,
Guido
|
|
|
|
|
Without seeing the code you used to call this and setup the parameters you passed in, it's pretty much impossible to tell you what's wrong.
|
|
|
|
|
 Hi,
mea culpa.
The code is as follows
public class MyRunAs
{
[DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
internal static extern bool CreateProcessWithTokenW(
IntPtr dupeTokenHandle,
LogonFlags dwLogonFlags,
string applicationName,
string commandLine,
CreationFlags dwCreationFlags,
IntPtr environment,
string currentDirectory,
ref STARTUPINFO sui,
out PROCESS_INFORMATION processInfo);
[DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
internal static extern bool DuplicateTokenEx(IntPtr tokenHandle, int
dwDesiredAccess,
ref SECURITY_ATTRIBUTES lpTokenAttributes, int
SECURITY_IMPERSONATION_LEVEL,
int TOKEN_TYPE, ref IntPtr dupeTokenHandle);
[DllImport("userenv.dll", SetLastError = true, CharSet = CharSet.Unicode)]
private static extern bool CreateEnvironmentBlock(
ref IntPtr lpEnvironment,
IntPtr hToken,
bool bInherit);
[DllImport("advapi32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
static extern bool CreateProcessAsUser(
IntPtr Token,
[MarshalAs(UnmanagedType.LPTStr)] string ApplicationName,
[MarshalAs(UnmanagedType.LPTStr)] string CommandLine,
ref SECURITY_ATTRIBUTES ProcessAttributes,
ref SECURITY_ATTRIBUTES ThreadAttributes,
bool InheritHandles,
CreationFlags dwCreationFlags,
IntPtr Environment,
[MarshalAs(UnmanagedType.LPTStr)] string CurrentDirectory,
ref STARTUPINFO StartupInfo,
out PROCESS_INFORMATION ProcessInformation);
[StructLayout(LayoutKind.Sequential)]
internal struct SECURITY_ATTRIBUTES
{
internal int nLength;
internal int lpSecurityDescriptor;
internal bool bInheritHandle;
}
public enum CreationFlags
{
DefaultErrorMode = 0x04000000,
NewConsole = 0x00000010,
NewProcessGroup = 0x00000200,
SeparateWOWVDM = 0x00000800,
Suspended = 0x00000004,
UnicodeEnvironment = 0x00000400,
ExtendedStartupInfoPresent = 0x00080000
}
public enum LogonFlags
{
WithProfile = 1,
NetCredentialsOnly
}
[StructLayout(LayoutKind.Sequential)]
internal struct STARTUPINFO
{
internal int cb;
[MarshalAs(UnmanagedType.LPTStr)]
internal string lpReserved;
[MarshalAs(UnmanagedType.LPTStr)]
internal string lpDesktop;
[MarshalAs(UnmanagedType.LPTStr)]
internal string lpTitle;
internal int dwX;
internal int dwY;
internal int dwXSize;
internal int dwYSize;
internal int dwXCountChars;
internal int dwYCountChars;
internal int dwFillAttribute;
internal int dwFlags;
internal short wShowWindow;
internal short cbReserved2;
internal IntPtr lpReserved2;
internal IntPtr hStdInput;
internal IntPtr hStdOutput;
internal IntPtr hStdError;
}
[StructLayout(LayoutKind.Sequential)]
internal struct PROCESS_INFORMATION
{
internal IntPtr hProcess;
internal IntPtr hThread;
internal int dwProcessId;
internal int dwThreadId;
}
const int SecurityAnonymous = 0;
const int SecurityIdentification = 1;
const int SecurityImpersonation = 2;
const int SecurityDelegation = 3;
const int TokenPrimary = 1;
const int TokenImpersonation = 2;
const int LOGON_WITH_PROFILE = 1;
const int LOGON_NETCREDENTIALS_ONLY = 2;
private const int TOKEN_QUERY = 0x0008;
private const int TOKEN_DUPLICATE = 0x0002;
private const int TOKEN_ASSIGN_PRIMARY = 0x0001;
private const int STARTF_USESHOWWINDOW = 0x00000001;
private const int STARTF_FORCEONFEEDBACK = 0x00000040;
private const int CREATE_UNICODE_ENVIRONMENT = 0x00000400;
private const int TOKEN_IMPERSONATE = 0x0004;
private const int TOKEN_QUERY_SOURCE = 0x0010;
private const int TOKEN_ADJUST_PRIVILEGES = 0x0020;
private const int TOKEN_ADJUST_GROUPS = 0x0040;
private const int TOKEN_ADJUST_DEFAULT = 0x0080;
private const int TOKEN_ADJUST_SESSIONID = 0x0100;
private const int STANDARD_RIGHTS_REQUIRED = 0x000F0000;
private const int TOKEN_ALL_ACCESS =
STANDARD_RIGHTS_REQUIRED |
TOKEN_ASSIGN_PRIMARY |
TOKEN_DUPLICATE |
TOKEN_IMPERSONATE |
TOKEN_QUERY |
TOKEN_QUERY_SOURCE |
TOKEN_ADJUST_PRIVILEGES |
TOKEN_ADJUST_GROUPS |
TOKEN_ADJUST_DEFAULT |
TOKEN_ADJUST_SESSIONID;
public static bool CreateTokenChild()
{
try {
STARTUPINFO startInfo = new STARTUPINFO();
startInfo.cb = Marshal.SizeOf(startInfo);
IntPtr dupeTokenHandle = IntPtr.Zero;
WindowsIdentity id = new WindowsIdentity("user@domain");
IntPtr tokenHandle = id.Token;
SECURITY_ATTRIBUTES lpTokenAttributes = new SECURITY_ATTRIBUTES();
lpTokenAttributes.nLength = Marshal.SizeOf(lpTokenAttributes);
bool retVal = DuplicateTokenEx(
tokenHandle,
TOKEN_ALL_ACCESS,
ref lpTokenAttributes,
SecurityImpersonation,
TokenPrimary,
ref dupeTokenHandle);
if (!retVal)
{
int winError = Marshal.GetLastWin32Error();
File.AppendAllText("C:\\tmp\\out.log", DateTime.Now.ToLongTimeString() + " " + winError + Environment.NewLine);
return false;
}
string app = @"c:\Windows\System32\notepad.exe";
string cmd = null;
string spath = @"C:\";
IntPtr env = GetEnvironmentBlock(dupeTokenHandle);
PROCESS_INFORMATION processInfo;
bool ret = CreateProcessWithTokenW(
dupeTokenHandle,
LogonFlags.WithProfile,
app,
cmd,
CreationFlags.UnicodeEnvironment,
env,
spath,
ref startInfo,
out processInfo);
if (!ret)
{
int winError = Marshal.GetLastWin32Error();
File.AppendAllText("C:\\tmp\\out.log", DateTime.Now.ToLongTimeString() + " error: " + winError + Environment.NewLine);
return false;
}
else
{
File.AppendAllText("C:\\tmp\\out.log", DateTime.Now.ToLongTimeString() + " success " + Environment.NewLine);
}
}
catch (Exception e)
{
return false ;
}
finally
{
}
return true;
}
private static IntPtr GetEnvironmentBlock(IntPtr token)
{
var envBlock = IntPtr.Zero;
if (!CreateEnvironmentBlock(ref envBlock, token, false))
{
throw new Win32Exception(Marshal.GetLastWin32Error(), "CreateEnvironmentBlock failed");
}
return envBlock;
}
}
Sorry for that lack of information. I somehow thought, its not code related but rather some security issue. I compared two processes with process explorer and the only thing that I realized was that "normal" processes have security attribute "NT AUTHORITY\INTERACTIVE" which the process I am starting has not ...
I also tried CreateProcessAsUser and it shows exactly the same behavior ...
Cheers and thanks.
Guido
|
|
|
|
|
I can't do impersonation here at work. I have to wait until I get home to examine the code.
|
|
|
|
|
gobbo-dd wrote: I compared two processes with process explorer and the only thing that I realized was that "normal" processes have security attribute "NT AUTHORITY\INTERACTIVE" which the process I am starting has not ... There's a nice hint.
If you ever created a Windows Service, you'll remember that you cannot access the desktop or interact with it if that flag is not set.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Yeah, I know. But according to the documentation here CreateProcessWithTokenW it says:
Quote: If the lpDesktop member is NULL or an empty string, the new process inherits the desktop and window station of its parent process. The function adds permission for the specified user account to the inherited window station and desktop. Otherwise, if this member specifies a desktop, it is the responsibility of the application to add permission for the specified user account to the specified window station and desktop, even for WinSta0\Default.
So how should I set this interactive flag if the function is supposed to take care of it ...
|
|
|
|
|
If it is running as another user, it may need to run on its own desktop.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I cant believe. First of all, there is this "runas" functionality which very well creates a GUI on the calling user's desktop. And secondly, the documentation says that it should work ...
Anyone has an idea why it doesn't? Or how I could assign the proper permissions to the process, I create ?
Thanks
Guido
|
|
|
|
|
gobbo-dd wrote: And secondly, the documentation says that it should work ... Where does it say that? On MSDN it states that there are two alternatives if the call fails with an ERROR_PRIVILEGE_NOT_HELD.
gobbo-dd wrote: Anyone has an idea why it doesn't? ..because (AFAIK) you can only interact with windows-objects that belong to your desktop-object; that is user-specific, as it is created after logon. You could create a new desktop-object and show it there.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hi,
it does not fail with "privilege not held" (i had that error 1342 and fixed it ...)
it even shows an icon in the taskbar (as you can see on the screenshot) - which indicates imho that the process is allowed to create "something" on the desktop....
it simply doesn't show the "full window"...
and yes, the documentation says:
Quote: If the lpDesktop member is NULL or an empty string, the new process inherits the desktop and window station of its parent process. The function adds permission for the specified user account to the inherited window station and desktop.
Quote: ..because (AFAIK) you can only interact with windows-objects that belong to your desktop-object; that is user-specific, as it is created after logon. You could create a new desktop-object and show it there.
Again - that is not what the documentation says "... process inherits ... "
Cheers
Guido
|
|
|
|
|
gobbo-dd wrote: which indicates imho that the process is allowed to create "something" on the desktop.... Which is what a service may do also, but it will not be showing a window unless it is marked as 'interactive'.
Found this[^] on SO, where the last answer suggests a possible solution
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
AWESOME
IntPtr hWinSta = GetProcessWindowStation();
WindowStationSecurity ws = new WindowStationSecurity(hWinSta, AccessControlSections.Access);
ws.AddAccessRule(new WindowStationAccessRule("user@domain", WindowStationRights.AllAccess, AccessControlType.Allow));
ws.AcceptChanges();
IntPtr hDesk = GetThreadDesktop(GetCurrentThreadId());
DesktopSecurity ds = new DesktopSecurity(hDesk, AccessControlSections.Access);
ds.AddAccessRule(new DesktopAccessRule("user@domain", DesktopRights.AllAccess, AccessControlType.Allow));
ds.AcceptChanges();
Did the trick. Thank you veeery much for pointing me to this.
Cheers
Guido
|
|
|
|
|
Thank you, for sharing your answer - bookmarked it for future reference
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Congratulations on a solution!
I was just looking at this again last night and didn't get anywhere.
|
|
|
|
|