Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / December 2004

Tip: Looking for answers? Try searching our database.

Making a PIA from an imported typelib

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Brian R. - 20 Dec 2004 18:57 GMT
I have a very custom case where a typelib relies on another typelib that does
not have a PIA.  We want to make our interop for our typelib a PIA.  We
cannot change our typelib at all (interfaces are cemented), so the decision
was to modify the interop assembly created from our type lib to manually
remove this dependency on the referenced non PIA type lib.

1. I ILDASM'd the interop to IL.
2. Modified the IL appropriately to remove dependence on other non PIA
interop.
3. Rebuild with ILASM and some questions...

Now to put it back into an interop that is designated as primary?  Can I
hand enter the metadata that makes it a PIA?  How do I make my interop
(rebuilt with ILASM) a PIA?  I can see that it offers signing capability, but
didn't see anyhting to mark it a PIA?  If it is simple metadata I can enter
it by hand in the IL.

THanks

Signature

Brian R.

"Peter Huang" [MSFT] - 21 Dec 2004 03:29 GMT
Hi

I think your steps is just OK.
Here is an article for your reference.

How can I customize my PIA?
Primary Interop Assemblies (PIAs)
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/ht
ml/whypriinterop.asp

Best regards,

Perter Huang
Microsoft Online Partner Support

Signature

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Brian R. - 21 Dec 2004 16:55 GMT
I tried these steps and was successful, but with concern.  I read the link
you mentioned, but for modifying an assembly step 1 is not successful for me
at all.  TlbImp fails to create a PIA for my assembly because I can't make or
get my hands on a PIA for MSXML.  MS told us not to sign it.  I can't change
my TLibs, so we were directed to modify the non signed interop to remove teh
MSXML dependency and then regen the type lib.  The problem is that I am not
starting from managed code, and the PIA attribute is not there.  

I added the PIA attr. to the IL, but I was guessing at some of the fields
based on other PIAs.  The IL looks like this that I added:

 .custom instance void
[mscorlib]System.Runtime.InteropServices.PrimaryInteropAssemblyAttribute::.ctor(int32,
                                                                           
                          int32) = ( 01 00 03 00 00 00 09 00 00 00 00 00 )

I was a little nervous to fill in the binary data for this Attribute.  The
Constructor shows Int32, Int32, but there are 12 bytes of data, not 8.  I can
tell which are the major and minor version (3.9 in this tlib's case), but I
don't know why the first value is  01 00 and the last it 00 00.  Not sure
what these values are setting, but they are in other PIAs and appear to work.


What do the first short and the last short of data refer to?  Is it OK to
hand enter this data in IL?  It worked now, but will it always?  

> Hi
>
[quoted text clipped - 13 lines]
> Get Secure! - www.microsoft.com/security
> This posting is provided "AS IS" with no warranties, and confers no rights.
"Peter Huang" [MSFT] - 22 Dec 2004 04:43 GMT
Hi

So I did not find any document about the usage of 01 00 and 00 00.
I think the leading 01 00 and the 00 00 is used for enbracing and
identifying the paramters attribute.
Based on my research, all the attribute's ctor. will have the 0100 and 0000
even if it is the defaul the ctor.

So far I think your solution is OK, also IL is kind of programming language
which is the base of all kind of other language(C#,VB.NET), so to change it
is OK. We can consider it as the "advanced" assembly language.

If you still have any concern, please feel free to post here.

Best regards,

Perter Huang
Microsoft Online Partner Support

Signature

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Mattias Sj?gren - 28 Dec 2004 00:01 GMT
>What do the first short and the last short of data refer to?  Is it OK to
>hand enter this data in IL?  It worked now, but will it always?  

00 01 can be seens as a tag or version number identifying the
attribute blob format, and the only value defined (so far) is 1.

00 00 indicates the number of named fields or properties that are set
by the attribute, in thiz case none.

So yes, that should always work.

Mattias

Signature

Mattias Sjögren [MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.


Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.