Unable to show output on login of user to Tridion [duplicate] - tridion

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to get tcmid of currently logged user in Tridion?
I wrote below code in class library(dll) and add assembly reference in config file od Tridion but i am unable to get any window or alert showing user.Id and its not giving any error.
[TcmExtension("Myevent")]
public class GetInfo : TcmExtension
{
public GetInfo()
{
EventSystem.Subscribe<User, LoadEventArgs>(OnUserLoad, EventPhases.TransactionCommitted);
}
private void OnUserLoad(User user, LoadEventArgs eventArgs, EventPhases phase)
{
MessageBox.Show(user.Id);
Console.WriteLine(user.Id);
}

It seems like you may be confusing event systems and GUI extensions. Your first line of code which subscribes and event handler is part of an event system, and can really only write to a log mechanism of some sort. What are you trying to achieve?
When you run your code in debug with Visual Studio on the CMS Server, does your code execute of hit any break points? Is your problem that the MessageBox doesn't show, or that your code does not run at all.

As I mentioned in my answer to your other question, you cannot use message boxes or console.writes to see information from an event system in SDL Tridion. You will have to revert to logging to the Tridion Event Log or debug your event system.
Remote debugging is possible as described in this msdn article, but I usually find it a nuisance to setup (provided you are not being blocked by firewalls between your dev machine and the CMS). So normally I simply revert to just instaling Visual Studio on the dev CMS server and debug the event system DLL directly from there, by attaching to the dllhost.exe process (see more details in this blog post).
And like I also mentioned in my answer to your other question, I'm still not convinced you can achieve your requirements in an event system. You might need to look at a UI extension or something completely different for logging active logins of a user. Technically, you are never logging into the SDL Tridion UI, since your password is validated by IIS, and not by the SDL Tridion web application.
ps. its better to edit your question if you want to give more info, its never a good idea to open up a duplicate question.

Related

Development and debugging in Dynamics 365

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");
}
}

Unable to add reference to third party WCF Service using Visual Studio

I recently received an updated integration document from a third party web services provider. One of the changes indicated that there are updated services that are located at a new URL.
I proceeded to delete my existing reference in my .NET 3.5 console application (VS2012) and attempted to add a new one pointing to the updated URL but was unable to do so due to the following error and die disabled "Add" button:
I subsequently tried to restore the reference to the old URL (which worked a mere month ago when I initially added it) but that to gave the same error.
I did a bit of googling and found the following posts that were not very encouraging:
Can't add Service Reference
Mixing Add Service Reference and WCF Web HTTP (a.k.a. REST) endpoint does not work
Don’t use “Add Service Reference”!
The first link simply repeated my problem statement. The second suggested there is no hope for me and the third is of no relevance since I do not control the server side component.
I was hoping someone with some more WCF experience possibly point me in the right direction. I suppose my question is twofold:
1: Is this something I am doing wrong on my side or can it be a problem with configuration on the third party server?
2: Is there any way I can reasonably add a reference to those services in my project without using "Add Reference" in VS, using the WSDL which I am able to download?
Edit: Just to calrify, the URL resolves and I can see the service controls and descriptions in both my browser and the VS window where you attempt to resolve the WS but the ".../$metadata" part in the error message above is not part of the original URL I entered. original URL which resolves fine is http://service.somewhere/service234/thing and the error refers to http://service.somewhere/service234/thing/_vti_bin/ListData.svc/$metadata

Error coming up when trying to open up file browser

Currently on my website i am trying to get it so that a user can upload an image from their local images. I have followed a tutorial, but when i debug it and try to open up my images folder i get this error message:
"Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it. This exception is only raised if a debugger is attached to the process."
Please can someone help me here, i have read a few posts; but seen as this is my first time doing this; i dont really understand them.
Thanks for any response!
You are trying to use Windows Forms functionality in a ASP.NET Web Page. Line 140:
FileDialog fldlg = new OpenFileDialog();
Windows Forms is desktop technology. You can't mix that with a ASP.NET web app. You can use the FileUploadControl to enable file uploads in your web application:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.fileupload.aspx

Debugging SDL Tridion 2011 Custom Resolvers and the GetListPublishItems() method

In one of my C# Template Building Blocks I have the following line of code
publication.GetListPublishItems(uriTarget, false, false,
TDSDefinesInterop.ListColumnFilter.XMLListDefault, listRowFilter);
Before implementing a Custom Resolver, this code executed very quickly. Now that my resolver is implemented for the Publication ItemType the code executes really slowly. From this I conclude that the new Resolver is being called behind the scenes by the GetListPublishItems() method (which makes sense). I assume I need to modify the resolver somehow. However I can't seem to hit a break point in my resolver when the method is called.
I normally attach to the 'TcmTemplateDebugHost' when debugging a template or directly to the publisher process when debugging the resolver. My Resolver only seems to get hit when I first press Publish and not when the GetListPublishItems() method is called.
So this question is twofold:
Do Resolvers get called when the GetListPublishItems() method is used?
Assuming they are called, which process should I attach to when I need to debug it in this scenario?
I don't know for certain, but I can't imagine a sane scenario where a custom resolver wouldn't be involved in GetListPublishItems(). Your evidence seems to back this up, but of course, if we can answer the second part of your question, we'll know it for certain.
I imagine that any normal assumptions you've made about the hosting process are probably correct, so for example, if you are invoking your template during a publish, then the TcmPublisher will be the process. Alternatively, if you were to open up the publish dialog for the publication in the GUI and hit "Show Items To Publish", then it would probably be the COM Surrogate process (dllhost.exe)... and so on. One way to find out for sure, though, is to use Sysinternals Process Explorer, which has a very handy feature that will allow you to search for which processes have a given dll loaded. (Look in the Find menu)
One likely cause for a breakpoint failing to bite is that Visual Studio isn't able to load the symbols correctly. When you're debugging a template building block, Tridion explicitly loads the symbols from a known location, which you can configure (tridion.templating/debugging/#pdbdirectory in the CM config), which is where the template uploader places the PDBs. When the publisher process loads the custom resolver, I doubt if there's any such special mechanism to locate the symbols, so you'll have to fall back to standard .NET methods. The first thing I'd try is to ensure your symbols for the custom resolver class are located in the same place as the assembly (i.e. your bin directory). Failing that you could perhaps configure a symbols path in Visual studio.
The first thing to do is to watch the debug output in Visual Studio. If you start the process and then attach to it, you will see the various assemblies being loaded. If Visual Studio can find the symbols, you will see that the output says "Symbols Loaded".

MessageBox.Show() not working in ASP.NET

I am trying to display some text using MessageBox.Show as shown below in a page_load event in ASP.NET. Before anyone jumps on the case why I am using it in ASP.NET, the use is for debugging only on my own dev box for a special need. There's a reference to System.Windows.Forms in the app.
I used it a few years ago so I know WinForm's MessageBox works. I am using .NET 4.0 and VS 2010. I don't think anything related to this function has changed.
MessageBox.Show("Message", "Caption", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); //used also ServiceNotification option
Any ideas why the message box doesn't display? I have only that line in the code.
ADDITION:
I am VERY AWARE of the message box thing implications. It's a temporary thing for debugging only. The line won't go into production. I have no access to javascript. Please put your thought into why it doesn't work instead of why I shouldn't be using it. I have used it before in 2.0 and it does work. I want to know if the newer .NET changed anything or I misused the option.
Direct Answer: it works in Visual Studio's web server , not in IIS.
The web application is hosted in a process that does not have a desktop, so you cant see any messageboxes.
#Tony, if you add System.Winform.dll to your rference, then you will be able to call message box.show at you development machine. But when you deploy it to some live server it will not work. So alternatively, you need to use javascript alerts. For this you can use this
private void ShowMessage(string message)
{
ScriptManager.RegisterClientScriptBlock(control, GetType(),"key","string.format("alert('{0}');",message),true);
}
Back in .Net 2.0 days, you could do this by including system.windows (I think) in your using statement.
Then, in the method, it would be system.windows.forms.Messagebox.show("foo");
I won't presume to tell you "yer doin it wrong"...
Just be aware that this will only show up on the server box, and could cause issues in a production environment.
The alert() is better, and console.log() is even better.

Resources