Gemini Community Support Site

This Gemini community support site can be used to find solutions to product issues. You can log in using Open Id, Google Profile and even Facebook. Feel free to ask a question or browse FAQs and documentation. Product tour videos are also available along with how-to videos demonstrating key Gemini capabilities.




Exception thrown by the target of an invocation - CreateAttachment

api

Hello. I am receiving the "Exception thrown by the target of an invocation" error when calling the CreateAttachment method.

I know that attachments themselves are working, as I can add attachments to issues via the Gemini application.

I have looked through the code in CounterSoftGeminiAPISamplesv354.zip and I cannot find any examples that use the CreateAttachment method. I have run a grep against all the samples I've downloaded, searching for the strings "attach" and "FileEN", but "attach" matches only the CounterSoft DLLs, and the only match for "FileEN" that is not in a DLL is actually commented out (FormIssue.cs, line 375).

I had been receiving the "Exception thrown by the target of an invocation" error from the CreateIssue method earlier and it turned out to be a setup issue.

Are there any special permissions other than View Project and Create Issue that are required to allow a user to create an attachment for an issue? I have actually tried it using an administrative account to create the IssuesServices object but it still fails.

Here is my test code:

        IssuesService issueService = new IssuesService("http://gemini.unbc.ca/gemini", "IssueCreator", "IssueCreator", "tsxzja68i8");        if (ulFormatSampleFile.Enabled && issue.IssueID > 0)        {            HttpPostedFile postedfile = ulFormatSampleFile.PostedFile;            int filelength = postedfile.ContentLength;            byte[] filebytes = new byte[filelength];            postedfile.InputStream.Read(filebytes, 0, filelength);            FileEN theFile = new FileEN();            theFile.ProjectID = 10;            theFile.FileName = postedfile.FileName;            theFile.FileData = filebytes;            theFile.ContentType = postedfile.ContentType;            theFile.ContentLength = filelength;            theFile.State = BaseEN.EntityState.New;            try            {                issueService.CreateAttachment(issue.IssueID, theFile);            }            catch (Exception ex)            {                Response.Write(ex.Message);            }        }

I have also used the code found in this post (http://support.countersoft.com/forums/thread/8600.aspx) as a sample, but it doesn't work either.

Can somebody post a working example of the CreateAttachment web service method, or tell me if there is any special permission/setup that needs to be done for a user to be able to create attachments?

Thanks,
Pablo

pablo
· 1
pablo
Replies (1)
helpful
0
not helpful

Please set the IssueID of the FileEN and make sure that the issue belongs to that project (theFile.ProjectID).


Mark Wing
· 9108
Mark Wing