Microsoft KB Archive/815636

= DOC: &quot;File or assembly name EventSrc, or one of its dependencies, was not found&quot; Error When You Export the Assembly to a Type Library by Using TlbExp.exe =

Article ID: 815636

Article Last Modified on 5/12/2007

-

APPLIES TO


 * Microsoft .NET Framework 1.0
 * Microsoft .NET Framework 1.1

-



SYMPTOMS
When you follow the steps in the &quot;Raising Events Handled by a COM Sink&quot; MSDN article, you receive the following error when you export the assembly to a Type Library by using Tlbexp.exe:

TlbExp error: File or assembly name EventSrc, or one of its dependencies, was not found.

For additional information, click the following link to view the &quot;Raising Events Handled by a COM Sink&quot; MSDN article:

Raising Events Handled by a COM Sink

http://msdn2.microsoft.com/en-us/library/dd8bf0x3(vs.71).aspx



CAUSE
You can specify the CustomInterfaceAttribute with a string parameter. The string argument must specify the event source interface. The string argument can also specify the strong name of the assembly. The strong name must be separated by a comma. In the &quot;Raising Events Handled by a COM Sink&quot; MSDN article, the EventSrc in the ComSourceInterfaces attribute string argument specifies the assembly that the event source is defined in. The default assembly name property for the example is set as ClassLibrary1 (the default name of your project). When the Type Library Exporter (TlbExp) Microsoft .NET Framework tool exports the event source interface from an assembly, it interprets the attributes associated with the class. TlbExp expects the event source interface that is defined by the ComSourceInterfaces attribute to be in an assembly named EventSrc.



RESOLUTION
To resolve the problem in the code, use one of the following four methods:  Remove the reference for the assembly from the ComSourceInterfaces attribute. To do this, follow the steps for one of the following samples:  Microsoft Visual Basic Sample  Make the following change to your code sample:

Replace

 _

with

 _

Note You must make this change at line 25 of the Visual Basic sample for the Managed server (event source) code. Clear the Root namespace property for the project. To do this, follow these steps:  In Solution Explorer, expand the Project node, and then click Properties. In the Project Property Pages dialog box, click to select General under Common Properties.</li> Clear the contents of the Root namespace property. Click OK.</li></ol> </li></ol> </li> Microsoft Visual C# Sample Make the following changes to your code sample:

Replace

[ComSourceInterfaces(&quot;EventSource.ButtonEvents, EventSrc&quot;)]

with

[ComSourceInterfaces(&quot;EventSource.ButtonEvents&quot;)]

Note You must make this change at line 21 of the Visual C# sample for the Managed server (event source) code.</li></ul> </li> Instead of using the string argument for the ComSourceInterface attribute, use the type argument. To do this, use one of the following samples. <ul> Visual Basic Sample <ol style="list-style-type: lower-alpha;"> Make the following change to your code sample:

Replace

<ComSourceInterfaces(&quot;EventSource.ButtonEvents, EventSrc&quot;)> _

with

<ComSourceInterfaces(GetType(EventSource.ButtonEvents))> _

</li></ol>

Note You must make this change at line 25 of the Visual Basic sample for the Managed server (event source) code.</li> Visual C# Sample Make the following changes to your code sample:

Replace

[ComSourceInterfaces(&quot;EventSource.ButtonEvents, EventSrc&quot;)]

with

[ComSourceInterfaces(typeof(EventSource.ButtonEvents))]

Note You must make this change at line 21 of the Visual C# sample for the Managed server (event source) code.</li></ul> </li> Change the assembly name to EventSrc in Visual Studio .NET. To do this, follow these steps to change the default value of the Assembly Name property: <ol style="list-style-type: lower-alpha;"> In Visual Studio .NET, expand the Project node in Solution Explorer, and then click Properties.</li> In the Project Property Pages dialog box, click General under Common Properties.</li> Change the default value of the Assembly Name to EventSrc in the right pane of the Project Property Pages dialog box. Click OK.</li> For the Visual Basic sample, clear the contents of the Root namespace property. To do this, follow these steps: <ol> In Solution Explorer, expand the Project node, and then click Properties.</li> In the Project Property Pages dialog box, click to select General under Common Properties.</li> Clear the contents of the Root namespace property. Click OK.</li></ol> </li></ol> </li> When you create the Visual Basic project or the Visual C# project in Visual Studio .NET to test the sample code, set the name of the project to EventSrc.

For the Visual Basic sample, clear the contents of the Root namespace property. To do this, follow these steps: <ol style="list-style-type: lower-alpha;"> <li>In Visual Studio .NET, expand the Project node in Solution Explorer, and then click Properties.</li> <li>In the Project Property Pages dialog box, click to select General under Common Properties.</li> <li>Clear the contents of the Root namespace property. Click OK.</li></ol> </li></ol>

<div class="moreinformation_section">

MORE INFORMATION
The &quot;Raising Events Handled by a COM Sink&quot; MSDN article describes how to interoperate a .NET Framework event source with a COM event sink. The example in the article defines an event sink interface with a managed event source. The component that sources the events is associated with the event sink interface by using the ComSourceInterfaces attribute. The ComSourceInterfaces attribute discussed in the sample is stated as follows: [ComSourceInterfaces(&quot;EventSource.ButtonEvents, EventSrc&quot;)] The code is compiled and TlbExp is used to generate a Type Library. A COM client uses the Type Library to sink the events that are raised by the managed server. When this behavior occurs, you receive the error message that is described in the &quot;Symptoms&quot; section of this article.

Keywords: kbdocerr KB815636

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.