how to assign Strong Name to an Assembly? - assemblies

I have created strong name using -
sn -k C:\strong.snk
nao how to assign this key to any assembly? and where I have to use gacutil?

This is going on the assumption of a .NET Framework project in Visual Studio.
Project Menu
[Project Name] Properties
Signing
Check "Sign the assembly"
Click the "Choose a strong name key file:" drop down then click ""
Find your key and select!
...?
Profit!

Related

EncryptionProvider in Office add-in ( VSTO or COM )

I'm having a problem of finding the right way to use EncryptionProvider property of Word.Document class in VSTO add-in for Word.
Every time I try to set any value (Add-in 'ProgId', other encryption providers, random strings) to it I receive OutOfMemoryException.
I tried implementing Office.EncryptionProvider interface in addIn class and in separate class and non of it's methods gets executed at all. After I set any value to EncryptionProvider VSTO executes RequestService override of my add-in object asking for Office.EncryptionProvider GUID object, but whatever I return there it does nothing (at least no exceptions or anything visible).
Problem worsens as MSDN or any other documentation I have found had minimal description ( and obvious based on method/class names) and no examples.
So what is the correct way of using EncryptionProvider in Office add-in?
In your VSTO add-in you need to implement the EncryptionProvider interface. You must return an instance of this interface when a correspodning guid is requested in the RequestService overridden function.
Then try to do the following steps:
Open the windows registry editor (regedit.exe).
Look for the following registry subkey:
HKEY_CURRENT_USER\Software\Microsoft\Office\XX.0\Common
Create a new Key there.
Type Security, and then press ENTER.
Locate the following registry subkey:
HKEY_CURRENT_USER\Software\Microsoft\Office\XX.0\Common\Security
On the Edit menu, point to New, and then click String value.
Type DeprecatedProviders, and then press ENTER.
In the Details pane, right-click DeprecatedProviders, and then click Modify.
In the Value data box, type The Custom CSP Name, and then click OK.
Exit Registry Editor.
Where the XX.0 is the Office version installed on your machine. I suppose that now your add-in should work correctly with Word.
See Custom Encryption in VSTO for more information.

"Unable to look up library. Check the ID and access permissions and try again." Firebase Google Apps Script

I am unable to find the Firebase library for Google Apps Script.
I followed the following instruction:
https://sites.google.com/site/scriptsexamples/new-connectors-to-google-services/firebase
The in this article mentioned project key / script id can not be found when trying to add the library in my new project.
The Look Up renders:
Unable to look up library. Check the ID and access permissions and try again.
Am I missing something? Am I doing something wrong?
Use the Script ID
as opposed to the Project Key
For this library it's:
1hguuh4Zx72XVC1Zldm_vTtcUUKUA6iBUOoGnJUWLfqDWx5WlOJHqYkrt
New editor vs Legacy
With the move to the new editor, using Project Keys no longer work.
See the different instructions for the New vs Legacy Editor in the docs:
https://developers.google.com/apps-script/guides/libraries
Adding a library if you only have the Project Key
If you can't find the ID for a particular script, while the Legacy editor is still available you can switch to the Legacy editor to add it with a Project Key, and then switch back to the new editor.
Finding the Script ID if you only have the Project Key
Maybe you want to get the ID for later reference. To get this, once you have it added, you can press the "three dots" button next to the library name and select "Open in new tab". Once you have it open, you can get the ID from the URL.
I came here because I tried to use a deployment id for a script library.
The fix was to use the project id which I found under project settings.
The answer from 'iansedano' is correct. I just want to add that a to get the 'script id' it's easier to just go to the settings and copy it from there:

Locating the source DLL behind a COM+ ProgId

I've never really had to debug Classic ASP, so this is a little rough and most likely a poor question, but I have done as much research as I could before asking.
I have a request to identify what code prints to a printer, and re-use that code in a new page that someone has built.
While trying to identify that, I've stumbled on a few things that I don't understand, but namely one big one.
The gist is, people can order cookies from the cafeteria, and when they submit, it shows a confirmation page and that order is sent to a printer.
To get a list of cookie options, there's a Server Object created, and from there a method exists, but I cannot identify where it is or where I should be looking. Here's the code:
<%
On error resume next
Const CATAGORY_COOKIE = 1
Dim cookieNames
Dim objCookie
Dim Count
Set objCookie = Server.CreateObject("CookieOrder.CookieRequest")
if objCookie Is Nothing then
Response.Write "Error"
Response.End
End if
cookieNames = objCookie.getAvailable_Item_Names(CATAGORY_COOKIE)
Count = objCookie.Count
Dim sz
sz = Split(cookieNames, ";")
Set objCookie = Nothing
%>
How do I identify what the Server Object is? There's a .dll file that contains binary, but I'm not familiar with how that could be utilized.
I have tried to follow the browser dev tools, but they really haven't been too helpful in this aspect.
I am hoping that learning how this code is executing or where it's being executed I will figure out my other problems.
Bit of background
The project is using a COM+ component. These are defined in Classic ASP using the syntax;
Set obj = Server.CreateObject("[insert COM+ ProgId]")
In this project you are using a component registered with the ProgId
CookieOrder.CookieRequest
There are many out of the box COM+ components available to Classic ASP that provide a lot of common functionality such as;
Visual Basic Scripting Runtime
ActiveX Data Objects
There is also the ability to create COM+ components for use with Classic ASP using languages common to the time like Visual Basic, Visual C++ and more recently using the .NET Framework (C#, VB.NET).
How to locate COM+ libraries
NOTE: Please be careful when accessing the registry as modifying or deleting keys could lead to a corrupt operating system.
Also for the purposes of this guide will use the Scripting.Dictionary ProgId.
The key is using the ProgId to find an elusive COM+ library.
Start %SystemRoot%\system32\regedit.exe (will work in most Windows Operating Systems)
Navigate to the HKEY_CLASS_ROOT hive and select it, then press Ctrl + F to open the Find dialog box.
In Find what type the ProgId in this case Scripting.Dictionary and make sure in look at only Key is checked then press Find or Find Next.
If a ProgId key is found expand to the key and locate the CLSID key which contains a (Default) REG_SZ with the value of the CLSID in the case of this example {EE09B103-97E0-11CF-978F-00A02463E06F}. Double click this value to bring up the Edit String dialog copy the value into your clipboard.
Return to the HKEY_CLASS_ROOT key and use Find to search for the CLSID value which in this example is {EE09B103-97E0-11CF-978F-00A02463E06F} and again make sure Look at has only Key checked then press Find or Find Next.
If the key is found expand and locate the InprocServer32 key in it you will find the location of DLL in the (Default) REG_SZ value. In this example that is C:\Windows\System32\scrrun.dll (this will be different depending on installation location and OS)
What about decompiling?
There's a lot of assumption in the comments about the compiler used to compile the DLL (mainly .NET), but the best way to check is to use one of the many programs out there in the public domain designed for this purpose.
There is a specific question on SO that deals with this;
Answer by #simon-mᶜkenzie to Identifying the origin of a DLL

Cannot reference another database project in solution

In SSDT 2013, I can't reference another project in the same solution. That project manages another database on the same server. It lets me pick the project, setup the database name and variable, but the OK button is disabled.
If I pick the option that it is in the same server, the OK button enables (but doesn't help, as it is in another database on the same server).
What is causing this? Am I missing some configuration on one of the projects to allow referencing?
In the "Add Database Reference" dialog box, try deleting the contents of the "Database variable" text box. That should enable the OK button.

How to class c# function in asp classic [duplicate]

After going through a number of different articles and not finding anything especially conclusive that takes me step-by-step through the process, I've come seeking help.
The Scenario
A client of mine is only proficient in development for ASP Classic. They have recently acquired an account for a site originally written in ASP.NET. They are rolling the site into something they can actively maintain, but the site originally included an image handler that took dynamically changing data regarding water levels and outputs an image containing a graphical representation of that data. The requirement is to develop a COM interop library that can be registered on the server and called with CreateObject to generate the same image's byte array for output using Response.BinaryWrite. The COM interop library must be registered at the remote site on a Windows 2000 Server, and I can't make any assumptions about their having access to regasm/gacutil to accomplish that task.
The Difficulty
I've built the class library by creating a Class Library project in Visual Studio 2010, choosing "COM Class" from the template, and inserting my code to generate a class with a single public method to return a byte array when given an integer (well, enumerator, but all the same). Unfortunately, even on my own development machine after building the library and registering (regasm) and caching the assembly (gacutil), I can't make a call through Classic ASP to instantiate the object, receiving instead an "ActiveX component can't create object" error. And, of course, at the server site, the DLL file can't be registered, the response being "Required module was not found."
Resources I've Used
I've already had a look through the following articles and haven't turned up the answers I need:
(Basic steps) Walkthrough: Creating COM Objects with Visual Basic
Build and Deploy a .NET COM Assembly
.NET COM+ Interop Component with Classic ASP
What I Need
Essentially what I need is a bit of hand-holding on a kind of step by step of what it's going to take to meet the requirements and create a COM+ interop module correctly in Visual Studio 2010. Creating the actual class object itself isn't terribly difficult.
However, none of the articles I've looked through really discuss project options or build procedures with Visual Studio 2010 or the .NET 4.0 Framework, nor have any of them really discussed if there are special considerations for deploying to older systems like Windows Server 2000 and the actual registration of the library on a system with only, say, regsvr32 on hand.
It should be fairly straightforward to get a basic .NET assembly exposed to COM - I've never tried the COM Class project template, so this is the way I've managed it in the past:
Create a new (bog standard) .NET class library using C# or VB. Define a COM interface (replace GUIDs with your own):
[ComVisible(true)]
[Guid("8999F93E-52F6-4E29-BA64-0ADC22A1FB11")]
public interface IComm
{
string GetMyGroups();
}
Now define a class that implements that interface (again, replace GUIDs with your own):
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None)]
[GuidAttribute("C5C5A1A8-9BFB-4CE5-B42C-4E6688F6840B")]
[ProgId("Test.Comm.1")]
public class Comm : IComm
{
public string GetMyGroups()
{
var comm = new CommunicatorAPI.MessengerClass();
var groups = comm.MyGroups as IMessengerGroups;
return string.Join(", ", groups.OfType<IMessengerGroup>().Select(g => g.Name).ToArray());
}
}
The Prog ID attribute on this class is what you will use to instantiate your component from ASP.
Strongly-name the assembly (Project properties -> "Signing" tab -> "Sign the assembly" -> Create a new strong name key file using the dropdown)
Now, build the assembly, and register using Regasm - if you don't wish to register in the GAC (which i'd recommend, as not GACing keeps the deployment simpler), be sure to use the -Codebase parameter (this just adds a reg entry that tells clients where to find the assembly) - e.g:
regasm ClassLibrary2.dll /codebase "S:\Testing\ClassLibrary2\ClassLibrary2\bin\Debug\ClassLibrary2.dll"
Now you should be able to instantiate the component, and call methods on it - for example (in javascript):
var a = new ActiveXObject("Test.Comm.1");
alert(a.GetMyGroups());
When it comes to deployment, the important work that Regasm and Regsvr32 do is to write various settings into the registry, so that clients can find the COM component (based on Prog ID, or COM Class ID). All you need to do is work out what COM settings are being written when you run Regasm on your local machine, and write these to the registry on the server. You can use ProcMon to monitor what gets written to the registry when Regasm is run.
Generally speaking, you can expect to see something like this written to the registry:
[HKEY_CLASSES_ROOT\Test.Comm.1]
#="ClassLibrary2.Comm"
[HKEY_CLASSES_ROOT\Test.Comm.1\CLSID]
#="{00585504-90C8-4760-A359-67CAF08FFED1}"
[HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{00585504-90C8-4760-A359-67CAF08FFED1}]
#="ClassLibrary2.Comm"
[HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{00585504-90C8-4760-A359-67CAF08FFED1}\Implemented Categories]
[HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{00585504-90C8-4760-A359-67CAF08FFED1}\Implemented Categories\{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}]
[HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{00585504-90C8-4760-A359-67CAF08FFED1}\InprocServer32]
#="mscoree.dll"
"ThreadingModel"="Both"
"Class"="ClassLibrary2.Comm"
"Assembly"="ClassLibrary2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cf55d4e60653257a"
"RuntimeVersion"="v4.0.30319"
"CodeBase"="file:///S:/Testing/ClassLibrary2/ClassLibrary2/bin/Debug/ClassLibrary2.DLL"
[HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{00585504-90C8-4760-A359-67CAF08FFED1}\InprocServer32\1.0.0.0]
"Class"="ClassLibrary2.Comm"
"Assembly"="ClassLibrary2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cf55d4e60653257a"
"RuntimeVersion"="v4.0.30319"
"CodeBase"="file:///S:/Testing/ClassLibrary2/ClassLibrary2/bin/Debug/ClassLibrary2.DLL"
[HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{00585504-90C8-4760-A359-67CAF08FFED1}\ProgId]
#="Test.Comm.1"
Hope this helps :)
I have a Classic ASP web site that uses a VB6 COM object. I wanted to create a new version of the COM object using .NET instead of VB6. This is how I did it (hope this helps). I include instructions for both C# and VB.NET.
[01]
Start Visual Studio 2015 (run as admin).
Create a new "Class Library" project.
Name it: "DotNetCom"
[02] C#
Add a new class, name it "HelloCOM".
Use the following code as starting template
( visit https://msdn.microsoft.com/en-us/library/c3fd4a20.aspx for more info )
using System.Runtime.InteropServices;
namespace DotNetCom
{
[Guid("EAA4976A-45C3-4BC5-BC0B-E474F4C3C83F")]
public interface HelloCOMInterface
{
[DispId(1)]
string Hello();
}
[Guid("7BD20046-DF8C-44A6-8F6B-687FAA26FA71"),
InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface HelloCOMEvents
{
}
[Guid("0D53A3E8-E51A-49C7-944E-E72A2064F938"),
ClassInterface(ClassInterfaceType.None),
ComSourceInterfaces(typeof(HelloCOMEvents))]
public class HelloCOM : HelloCOMInterface
{
public string Hello()
{
return "Hello there!";
}
}
}
[02] VB.NET
Add a new "COM class", name it "HelloCOM".
VB.NET creates the starting template.
Add the following function to the "HelloCOM" class.
Public Function Hello() As String
Return "Hello there!"
End Function
[03] C#
Open the project properties.
Go to "Application".
Click "Assembly Information...".
Check "Make assembly COM-Visible"
Go to "Build".
Select "Platform target: x86".
Check "Register COM for interop"
[03] VB.NET
Open "MyProject".
Go to "Compile".
Select "Target CPU: x86".
[04]
Build the "DotNetCom.dll".
[05]
Open a command prompt (run as admin).
Change directory to your dll.
cd DotNetComTest\DotNetComTest\TX7NGN.COM\bin\Debug
Run RegAsm /codebase.
C:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm DotNetComTest.dll /codebase "C:\DotNetComTest\DotNetComTest\bin\Debug\DotNetComTest.dll"
[06]
Start Component Services.
Add a new COM+ application.
Name it: "DotNetCom".
Open the "DotNetCom" properties.
Go to the "Security Tab".
UNCHECK "Enforce access checks for this application".
[07]
Add a new component.
Select "DotNetComTest.tlb" (do NOT select "DotNetComTest.dll").
[08]
Use the COM object from the Classic ASP page.
<%
Dim HelloCOM
Set HelloCOM = Server.CreateObject("DotNetCom.HelloCOM")
Response.Write HelloCom.Hello
%>

Resources