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.
Related
I’ve upgraded a custom model to Dynamics 365, from Ax2012. I’ve created deploy-able package and imported into an on-prem environment.
The machine on which I developed is different from the on-prem environment (TEST-env).
There is some functionality that is not working as it should, which I need to debug, and this is where I get stuck.
I’ve been developing in Ax from version 3 to 2012. I am struggling to get comfortable and find my way in Visual Studio.
In a broad sense I guess my question is: how do I debug something as simple as a button click event on a form? Can I run the form from Visual Studio and debug it there, without having to open the Dynamics 365 website?
Since my development environment and the on-prem D365 website (TEST-env) are on two different machines, is there an easy way to make changes to the code and have the TEST-env updated, or do I have to create a deployment package and import it into TEST-env for each change?
To debug, you just create a project with your objects, right click on a form and click "Set as Startup Object" then go put a breakpoint (F9) on whatever line of code, and press F5 to run.
You could connect your Test version to VSTS and do code moves that way via branch/merging.
Your development environment is an entirely isolated version meaning typically your database and the application all live on the same box and all the D365 services run from that one box. IIS is configured to run your instance so when you browser to D365 you are viewing your development environment.
Typical debugging involves placing break points in the code, normally if you know there is code behind a button click you want to break into you would find the form where the button is right-click and get the form name. Then open visual studio 2015 which is the exclusive IDE for development. Find the AOT explorer and paste in the form name. Then open the form once it is in the explorer, find the button and look at the methods, events of that and view the code. From there you can put break points and you just have to attach the debugger to w3wp.exe. Make sure you go into the options under the Dynamics 365 menu and find debugging and make sure to uncheck "Load symbols only for items in the solution" or your break point won't get unless it is something in your project.
The other option you have with debugging is to create what is called a runnable class in D365. You create a new class and add a void main entry and then right-click on the class from the solution explorer and select "set as startup object". Then you can just press the start button from visual studio and that class will fire. This allows you to easily debug scenarios where you are checking what a select in X++ returns or items like that. You can't run the D365 site from pressing start, only simple runnable classes.
Example of a runnable class in D365
class TestClass
{
public static void main(Args _args)
{
Info("hello world");
}
}
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
I get the following error with a legacy asp application that I have been asked to help out with.
Server object error 'ASP 0177 : 800401f3'
Server.CreateObject Failed
/site_manager/image_upload.asp, line 27
800401f3
The line ofcode that throws the error is shown below:
Set fbase = Server.CreateObject("chili.upload.1")
As you ahve probably guessed oldschool asp isn't my strong point but from the research I have done it seems as if a component hasn't been registered on the server (I only have FTP access).
What component needs to be regsistered?
Thanks for the help...
You're missing the registration of the DLL that creates the chili.upload.1 object. Are you trying to run this on a Linux machine?
You need to register the Sun Chili!Soft ASP components. Here's the manual on this from 2003:
http://ns7.webmasters.com/caspdoc/html/running_the_setup_program_sun_chili_soft_asp_for_windows.htm. Note that this only works if you still have the original setup. Otherwise you're out of luck. Sun Chili!Soft ASP is no longer available and very, very dead.
If you're just interested in file upload functionality on ASP, I can recommend Free ASP Upload. It requires no registration of any components and generally works. I can also recommend this article on the topic of ASP uploads. If you're willing to shell out some money there are hundreds of components that do the same thing too.
Register the DLL on your computer, and then do this:
Locate and then click the following registry subkey:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\
FeatureControl\FEATURE_IGNORE_ZONES_INITIALIZATION_FAILURE_KB945701
Note If the FEATURE_IGNORE_ZONES_INITIALIZATION_FAILURE_KB945701 subkey does not exist, you must manually create it. If you're using a 64 bit OS, you may need to use HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\ FeatureControl\FEATURE_IGNORE_ZONES_INITIALIZATION_FAILURE_KB945701 instead
Right-click FEATURE_IGNORE_ZONES_INITIALIZATION_FAILURE_KB945701,
point to New, and then click DWORD Value
Type w3wp.exe to name the new registry entry, and then press ENTER.
Right-click w3wp.exe, and then click Modify.
In the Value data box, type 1, and then click OK.
After setting this registry key, a simple app pool restart will apply the change. No longer will your .NET COM components randomly stop working with no real solution except shuffling application pools!
Is anyone aware of a Visual Studio 2010 Add-In that will automatically allow you to attach to a running instance of the ASP.Net Development Server? And if there is more than one currently running, display a quick dialog that lets you choose from a list of just the ASP.Net Development Servers that are running?
Why do I want this? <-- feel free to skip this part.
The way I usually develop / debug web applications is to launch a browser and navigate through the application until I get to the page I want (could be many pages deep.) I don't want to have the debugger attached through these steps for various reasons (it is slower than not having it attached, extraneous break-points may be hit, I may have break when "thrown" turned on and not want to break earlier in the app when handled errors are thrown, etc...)
I navigate to the page I want, then use the Visual Studio menus to Debug > Attach to Process, and then from within the Attach to Process dialog, I have to scroll all the way down (pages and pages and pages of processes) until I find the WebDev.WebServer40.EXE process I want and choose that.
Doing this makes me take my hands off the keyboard and use a mouse (something I generally try to avoid.)
And doing this seems needlessly repetitive since, if I am debugging an ASP.Net Web Application, I always want to attach to an instance of the WebDev.WebServer40.exe.
I prefer to do the exact same thing and it IS possible to bind it all to a keystroke with a macro.
Goto Tools > Macros > Macro IDE
Add a new module and use this code (the funky comments are for syntax highlighting)
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports EnvDTE90a
Imports EnvDTE100
Imports System.Diagnostics
Imports System.Collections.Generic
Public Module AttachingModule
Sub AttachToAspNET()
Try
Dim process As EnvDTE.Process
Dim listProcess As New List(Of String)
'' // uncomment the processes that you'd like to attach to. I only attach to cassini
'' // listProcess.Add("aspnet_wp.exe")
'' // listProcess.Add("w3wp.exe")
listProcess.Add("webdev.webserver")
For Each process In DTE.Debugger.LocalProcesses
For Each procname As String In listProcess
If process.Name.ToLower.IndexOf(procname) <> -1 Then
process.Attach()
End If
Next
Next
Catch ex As System.Exception
MsgBox(ex.Message)
End Try
End Sub
End Module
Click on File > Close and return
Click on Tools > Options
Click on Environment > Keyboard
I put the macro in MyMacros, so I look for "Macros.MyMacros.AttachingModule.AttachToAspNET" in the "Show Commands Containing" textbox".
I prefer to use Ctrl+Alt+D but put whatever you want in the "Press Shortcut Keys" textbox and click Assign, then OK
Now all you have to do is hit Ctrl+Alt+D to attach to all cassini instances.
I've seen various versions of this around the internets and this was the most recent I found. I had to modify that slightly to remove the extra web processes and to drop the .exe from WebDev.WebServer.exe, so that it would debug .net 4.0 instances of cassini.
I don't know of any such add-in but you can more easily attach to the process using shortcut keys and pressing 'W' to scroll to the WebDev process.
Ctrl+Alt+P - Attach to Process
(process window now has focus)
Press W, which jumps to processes starting with W
Press Enter to attach
Not an addin but you can do it without touching the mouse.
Check this answer out: Attach To Process in 2012
This is a simple plugin that gives shortcuts to attaching to nunit agent, IIS and IIS Express. Its pure convenience as compared to Ctrl-Alt-P, but it is convenient.
Direct link to the plugin here
My class derives from System.Web.Security.MembershipUser
I am getting this error when submitting the form. The popup form uses ASPPDFand the application did not have this problem before implementing the custom MembershipProvider goodies. Note this is a debugging error only. It seems to work when I am not debugging. Does anyone know how I can fix this?
NonComVisibleBaseClass was detected
Message: A QueryInterface call was made requesting the default IDispatch interface of COM visible managed class 'XyAmpUser'. However since this class does not have an explicit default interface and derives from non COM visible class 'System.Web.Security.MembershipUser', the QueryInterface call will fail. This is done to prevent the non COM visible base class from being constrained by the COM versioning rules.
Thanks,
~ck in San Diego
I have recently discovered this error in a totally unrelated scenario to yours.
Navigate to Debug->Exceptions...
Expand "Managed Debugging Assistants"
Uncheck the NonComVisibleBaseClass Thrown option.
Click [Ok]
Here is more information, which may help.
Just to keep this up to date:
In Visual Studio 2019: Debug Menu, Windows --> Exception settings, opens the Exception settings window. There expand "Managed Debugging Assistants" and finally uncheck NonComVisibleBaseClass
this is telling you that:
Your project contains some COM based objects which is not signed with a key to public usage.
There are 2 solution to this case:
1- Uncheck NonVisibleCome choice from the debugger settings
2- Find your objects code sign it and rebuild it.