|
I just have a question ( because I don't know very well how ngen works and if is change something to .exe file )
My question is :
If I have 2 version of exe file : one protected and one unprotected.
If I run ngen on user's computer with the unprotected .exe.
After can I use the protected exe ?
Thank you !
|
|
|
|
|
You'll be able to run the protected exe, but it won't have a pre-compiled native image, as it's a different assembly.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Quote: Hi everyone!
I'm making an application which requires users with different permissions/previleges to login and use the application.For example, if the user is "admin", all menu items in the menu bar are shown and enabled. If the user is say "user_group1", some of the menu items are to be hidden. The same for "user_group2", "user_group3", "user_group4" and so on.
I could put a code for each specific user in each form but that's a great deal since users and their user groups may be added after application deployment. So it has to be something flexible.
I want the user "Administrator" to be able to assign/change permissions to others users of the system.
How do I do this?
I have been thinking of creating a table that will include user_groups and permisions, say like a row: user_group (user_group1, user_group2,user_group3) and permission (File,Edit,Backup,Manage Users (these being menu items)) and then for each user I will be setting either "Yes" or "No" under each permission/menu item indicating that the menu item is to be hidden of shown.
But, I can read these permission to a dataset but I can't see how to link them with the menu items.
How should I accomplish this please?
What I have done so far:
I had to come up with 5 tables just for this, as a result, I can run an SQL query that will bring a user and the menu items which he/she is supposed to see. I have attached an image showing the results of such a query. Now I need to take what is in the table and effect it by enabling only the shown menu items ('permissionName' in my table). How can I? Since I have them in a dataset, is it possible to do some loop to accomplish that?
Sorry, it seems I can't upload an img in codeproject.com
|
|
|
|
|
savedlema wrote: How do I do this? Read up on roles, groups and users. There's an awfull lot of people who faced the same problem and who left an incredible amount of knowledge to start from.
savedlema wrote: But, I can read these permission to a dataset but I can't see how to link them with the menu items. You check what role someone is in, and only create those menu-items that are required for that specific role. That part would be done when you build the form.
savedlema wrote: I can run an SQL query that will bring a user and the menu items which he/she is supposed to see Good; create menus with those items
savedlema wrote: How can I? Since I have them in a dataset, is it possible to do some loop to accomplish that? Looping a dataset should not be a problem; Your question basically boils down to creating a menu-item during runtime. There's MSDN, Google, and the keyword "menu".
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Thanks a lot Eddy, but look, I'm not going to just create menu items at runtime, I have my menu items in a MenuStrip already. ToolStripMenu items are also stored in the database and will be fetched together with other items when I run a query to bring up a user and a list of menu items that he is allowed to see.
My problem is to take these permissions from a dataset/table and effect them by actually hiding and showing some menu items among many existing menu items.
To explain more, if the result of my query for permissions of "user5" is "FileToolStripMenuItem", "FileEditToolStripMenuItem" and "FileBackupToolStripMenuItem", now, how can I programmatically enable only those menu items in my MenuStrip1?
|
|
|
|
|
savedlema wrote: but look, I'm not going to just create menu items at runtime, I have my menu items in a MenuStrip already. Not very secure; what if (due to a bug) some items aren't hidden? It'd be better to create just the items you need in the first place.
savedlema wrote: now, how can I programmatically enable only those menu items in my MenuStrip1? Set the Enabled[^] property, e.g. "FileToolStripMenuItem.Enabled = false".
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hello !
I finish my application in vb.net 2013.
Now if I run the application (The final .exe outside Visual studio ) on my computer where I have created the application , everything works ok.
I install my application on another computer.But when I try to run I get an error :
Unable to find an entry point named "Draw ThemeBorder" on DLL "uxtheme.dll".
The application is created for .NET 4.0 (installed on both computers ).
Both computers have Windows 7 x32.
What can I do ?
Thank you !
|
|
|
|
|
|
Ok , but why I'm getting this message only on one computer. This is a problem with System or a problem of my program ?
Thank you !
|
|
|
|
|
Hello !
I found that the problem is the following Sub that is run when the main form is loaded :
Public Sub DoPrecompile()
For Each an As System.Reflection.AssemblyName In System.Reflection.Assembly.GetEntryAssembly().GetReferencedAssemblies()
Dim asmb As System.Reflection.Assembly = System.Reflection.Assembly.Load(an)
If Not asmb.GlobalAssemblyCache Then
For Each type As Type In asmb.GetTypes()
If Not type.IsInterface AndAlso Not type.IsGenericTypeDefinition Then
Dim ci As System.Reflection.ConstructorInfo = type.GetConstructor(System.Reflection.BindingFlags.[Static] Or System.Reflection.BindingFlags.[Public] Or System.Reflection.BindingFlags.NonPublic, Nothing, type.EmptyTypes, Nothing)
If ci = Nothing Then
For Each method As System.Reflection.MethodInfo In type.GetMethods(System.Reflection.BindingFlags.DeclaredOnly Or System.Reflection.BindingFlags.NonPublic Or System.Reflection.BindingFlags.[Public] Or System.Reflection.BindingFlags.Instance Or System.Reflection.BindingFlags.[Static])
If Not method.IsAbstract AndAlso Not method.IsGenericMethodDefinition AndAlso Not method.ContainsGenericParameters Then
System.Runtime.CompilerServices.RuntimeHelpers.PrepareMethod(method.MethodHandle)
End If
Next
For Each prop As PropertyInfo In type.GetProperties(BindingFlags.DeclaredOnly Or BindingFlags.NonPublic Or BindingFlags.[Public] Or BindingFlags.Instance Or BindingFlags.[Static])
For Each accessor As MethodInfo In prop.GetAccessors(True)
If Not accessor.IsAbstract AndAlso Not accessor.IsGenericMethodDefinition AndAlso Not accessor.ContainsGenericParameters Then
System.Runtime.CompilerServices.RuntimeHelpers.PrepareMethod(accessor.MethodHandle)
End If
Next
Next
End If
End If
Next
End If
Next
End Sub
If I remove this Sub everything is ok.
But on the computer where I have created the application everything works ok even with this Sub.
On another computer I have this error message.
|
|
|
|
|
You have not shown where the error occurs so it's difficult to guess. However it is quite possible that on the computer where the error occurs the version of the DLL in question is not the latest.
|
|
|
|
|
I'm copying a table from word then pasting the copied table in an Excel file.
Here is a code sample:
tbl.Range.Copy()
oSheet.Activate()
rng = oSheet.Range("A1")
rng.Activate()
rng.PasteSpecial(Excel.XlPasteType.xlPasteAll)
But when I do this, the table is pasted as a picture.
can anyone please help me with this?
|
|
|
|
|
Try using xlPasteValues rather than xlPasteAll
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
it works, i got the value but the table format is broken leading for the values to be apart. and also, i also need to copy the formats like alignment and attributes(bold, italics, etc...)
|
|
|
|
|
I added one line of code to copy cell E19 is ws1 to the next available row in column F in ws4. Everything is working except for pasting in column F on ws4. When I start using this, I need it to be in cell F18. Can you please help? Code below.
Dim ws1 As Worksheet, ws4 As Worksheet
Set ws1 = Sheets("Sheet1")
Set ws4 = Sheets("Sheet4")
With ws4
lMaxRows = .Cells(Rows.Count, "B").End(xlUp).Row
.Range("B" & lMaxRows + 1) = ws1.Range("D10").Value
lMaxRows = .Cells(Rows.Count, "C").End(xlUp).Row
.Range("C" & lMaxRows + 1) = ws1.Range("E22").Value
lMaxRows = .Cells(Rows.Count, "D").End(xlUp).Row
.Range("D" & lMaxRows + 1) = ws1.Range("D12").Value
lMaxRows = .Cells(Rows.Count, "E").End(xlUp).Row
.Range("E" & lMaxRows + 1) = ws1.Range("D14").Value
lMaxRows = .Cells(Rows.Count, "F").End(xlUp).Row
.Range("F" & lMaxRows + 1) = ws1.Range("E19").Value
End With
|
|
|
|
|
As per our current set up we are not passing any user id to connect but due to security concerns now we need to pass user id to connect to queue manager.Code is written in VB6.I have set MQSERVER variable with manager name and port name. Rest all the details are passing through code.
Actually application is running under "uprabc" but "bagabc" is the user id which authorised to connect.
SO i passed "bagabc" as alternate user id but i am getting 2035 error and as per logs uprabc id is getting passed. Please help in understanding where i am making a mistake or any step i missed.
Below is the code(using CMQB library for connection):
Private Function IBAAGMQConnect() As String
Dim CompCode As Long
Dim Reason As Long
Dim od As MQOD
Dim CnoCD As MQCNOCD
Dim QMgrName As String * MQ_Q_MGR_NAME_LENGTH
QMgrName = QManagerName
MQCONN QMgrName, gHcon, CompCode, Reason
If CompCode <> MQCC_OK Then
IBAAGMQConnect = "IBAAG MQ: Connection to Queue Manager failed. Reason: " & Reason & " Mgr Name is " & QMgrName
Exit Function
Else
IBAAGMQConnect = "0000"
End If
End Function
Private Function IBAAGMQOpen(FQueueName As String) As String
Dim CompCode As Long
Dim Reason As Long
Dim O_options As Long
Dim od As MQOD
If gHcon Then
MQOD_DEFAULTS od
od.ObjectName = FQueueName
od.ObjectQMgrName = QManagerName
od.AlternateUserId = AlternateUsedId
O_options = MQOO_OUTPUT + MQOO_INPUT_SHARED + MQOO_ALTERNATE_USER_AUTHORITY
MQOPEN gHcon, od, O_options, gHobj, CompCode, Reason
If CompCode <> MQCC_OK Then
Select Case Reason
Case Is = 2085
IBAAGMQOpen = "IBAAG MQ: Opening of " & Trim(FQueueName) & " failed. " & "ReasonCode = (2085) - MQRC_UNKNOWN_OBJECT_NAME: Check the spelling of the Queue name, which is Case-Sensitive."
Case Is = 2087
IBAAGMQOpen = "IBAAG MQ: Opening of " & Trim(FQueueName) & " failed. " & "ReasonCode = (2087) - MQRC_REMOTE_Q_MGR: Check the spelling of the Queue name, which is Case-Sensitive."
End Select
Exit Function
Else
IBAAGMQOpen = "0000"
End If
Else
IBAAGMQOpen = "IBAAG MQ: Opening of " & Trim(FQueueName) & " failed. " & Reason
End If
End Function
|
|
|
|
|
Here is my scenario
I have a Main Form and that form has 3 Menus
for each menu item I have a dialogbox (another form really)
in the main form I have the following sub
'To be called by a docking form (during its activation).
Public Sub SetCurrentDialog(dlg As Form)
m_curr_dlg = dlg
End Sub
for each of the menus I have the following
Private Sub Menu1_ItemClick(sender As Object, e As ItemClickEventArgs) Handles Menu1.ItemClick
SetCurrentDialog(Dilaog1)
Dialog1.ShowDialog(Me)
End Sub
Private Sub Menu2_ItemClick(sender As Object, e As ItemClickEventArgs) Handles Menu2.ItemClick
SetCurrentDialog(Dilaog2)
Dialog2.ShowDialog(Me)
End Sub
Private Sub Menu3_ItemClick(sender As Object, e As ItemClickEventArgs) Handles Menu3.ItemClick
SetCurrentDialog(Dilaog3)
Dialog3.ShowDialog(Me)
End Sub
in each of the Dialogs I have a Public Function as
Public Function ClientMouseUp()
'Do special MouseUp
End Function
on the MianForm I also have a PicturBox which I want to return information to the dialog
so I have
Private Sub PictureBox1_MouseUp(sender As Object, e As MouseEventArgs) Handles PictureBox1.MouseUp
m_curr_dlg.ClientMouseUp()
End Sub
But in the PictureBox1_MouseUp I get the following error
Error 39 'ClientMouseUp' is not a member of 'System.Windows.Forms.Form'.
Can anyone show me the errors of my ways?
|
|
|
|
|
typo?
SetCurrentDialog(Dilaog1)
or
SetCurrentDialog(Dialog1)
|
|
|
|
|
|
You need an Interface with the function ClientMouseUp, and all of your dialogs need to implement it.
|
|
|
|
|
I do not understand what you mean by interface.
I am trying to convert old VB6 code, which is why I am having the issue.
I am new to VB.net.
I am sorry in advance if I am asking a stupid question
|
|
|
|
|
This is now solved.
I can walk the code through and watch the data populate but nothing other than the headings are displayed. I am not sure what is different with this compared to others that have been done and i have even compared code and they all work the same so there must be something i am over looking.
Dim nUserID As Long
Dim sToday As String
Dim sUser As String
Dim sSQL As String
Dim li As ListItem
Me.lvMain.ListItems.Clear
Set dbGlob = OpenDatabase(GenPath & "WORORDGB.MDB")
sToday = sDate
Select Case UCase(sType)
Case "ALL"
sSQL = "SELECT * FROM [Accum] WHERE [Type] = 'LABOR' AND [Closed]= 0 AND [WOCounter] <> 0 ORDER BY [Date],[UserID],[Start],[WOCounter]"
Set rsCal = dbGlob.OpenRecordset(sSQL)
rsCal.MoveLast
rsCal.MoveFirst
Case "WO"
Set rsCal = dbGlob.OpenRecordset("SELECT * FROM [Accum] WHERE [Type] = 'LABOR' AND [Closed]= 0 AND [WOCounter] = " & CInt(Trim(Me.cmbWOID.Text)) & " ORDER BY [Date],[UserID],[Start],[WOCounter]")
rsCal.MoveLast
rsCal.MoveFirst
Case "WR"
Set rsCal = dbGlob.OpenRecordset("SELECT * FROM [Accum] WHERE [Type] = 'LABOR' AND [Closed]= 0 AND [WOCounter] <> 0 AND [UserID]=" & CLng(Me.cmbuserID.Text) & " ORDER BY [Date],[UserID],[Start],[WOCounter]")
rsCal.MoveLast
rsCal.MoveFirst
Case "WRWO"
Set rsCal = dbGlob.OpenRecordset("SELECT * FROM [Accum] WHERE [Type] = 'LABOR' AND [Closed]= 0 AND [WOCounter] = " & CInt(Trim(Me.cmbWOID.Text)) & " AND [UserID]=" & CLng(Me.cmbuserID.Text) & " ORDER BY [Date],[UserID],[Start],[WOCounter]")
rsCal.MoveLast
rsCal.MoveFirst
End Select
With Me.lvMain
If rsCal.RecordCount = 0 Then
Set li = .ListItems.Add(1, "ID" & rsUser.Fields("ID").Value, "Empty", , 4)
Exit Sub
End If
For X = 1 To rsCal.RecordCount
If IsNull(rsCal.Fields("UserID").Value) Then
sUser = rsCal.Fields("Desc").Value
Else
For Y = 0 To cmbUser.ListCount - 1
If CLng(rsCal.Fields("UserID").Value) = CLng(cmbuserID.List(Y)) Then
sUser = cmbUser.List(Y)
Exit For
End If
Next Y
End If
Set li = .ListItems.Add(X, "ID" & rsCal.Fields("Counter").Value, sUser, , 2)
li.SubItems(1) = Format(rsCal.Fields("Date").Value, "mm/dd/yyyy")
li.SubItems(2) = Format(rsCal.Fields("Start").Value, "hh:mm ampm")
li.SubItems(3) = Format(rsCal.Fields("End").Value, "hh:mm ampm")
li.SubItems(4) = Val(rsCal.Fields("Quantity").Value)
li.SubItems(5) = rsCal.Fields("WOCounter").Value
rsCal.MoveNext
Next X
End With
modified 30-May-14 15:34pm.
|
|
|
|
|
Initial suggestion: divide and conquer. Is is the listview or the data?
Try building your listview using other data; say, the numbers 1 to 10 and see what happens.
Also, try writing the database data to a text field, a file or the console window. Enjoy you're getting data when NOT in debug mode.
If they both work independently, then we can look at it again.
Having said that, VB 6 is no longer supported; consider moving to .NET. There are free versions available for download (VB.NET Express).
|
|
|
|
|
Thanks I am sorry i thought i deleted this thread. I did resolve the problem.
And yes I am migrating the complete application to newer code base using VS2013.
Thanks again
|
|
|
|
|
Hi everyone
I have the following to extract data from a SQL database and write it to an Excel table. I would likte to change the loop so that the data is copied to Excel per column rather than single field (to speed up th import):
'Create the connection string
sConnString = "Provider=SQLOLEDB.1;Data Source=SRV002982;" & _
"Initial Catalog=HFMDSmartFDM_QMR211;" & _
"Password=password;Persist Security Info=True;User ID=User"
'Create the Connection and Recordset objects
Set conn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
'Open the connection and execute
conn.Open sConnString
Set rs = conn.Execute(CommandString)
'Check data
If Not rs.EOF Then
nRow = nRow + 1
'Transfer result to WS
Do While Not rs.EOF
For Each elem In rs.Fields
nCol = nCol + 1
ws.Cells(nRow, nCol) = elem
Next
rs.movenext
Loop
End If
There are reasons I can't just splash the entire table. I need to import column by column. Any help is greatly appreciated
|
|
|
|
|